Part Number Hot Search : 
1N5416 LT1076CR 1N4148W N5415 MBR2H100 M12541DD TSOP3136 2N103J
Product Description
Full Text Search
 

To Download H83937R Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
 

preface the h8/300l series of single-chip microcomputers has the high-speed h8/300l cpu at its core, with many necessary peripheral functions on-chip. the h8/300l cpu instruction set is compatible with the h8/300 cpu. the h8/3937 series and h8/3937r series include, a flex decoder*, five kinds of timers, a 2- channel serial communication interface, and an a/d converter, as on-chip peripheral functions necessary for system configuration. the configuration of these series makes them ideal for use as embedded microcomputers in pagers using the flex decoder system. the h8/3937 series supports non-roaming, while the h8/3937r series supports roaming. this manual describes the hardware of the h8/3937 series and h8/3937r series. for details on h8/3937 series and 3937r series instruction set, refer to the h8/300l series programming manual. note: * flex is a trademark of motorola inc.

i contents section 1 overview ............................................................................................................ 1 1.1 overview ................................................................................................................... ......... 1 1.2 internal block diagram ..................................................................................................... .5 1.3 pin arrangement and functions......................................................................................... 6 1.3.1 pin arrangement ................................................................................................... 6 1.3.2 pin functions......................................................................................................... 7 section 2 cpu ..................................................................................................................... 13 2.1 overview ................................................................................................................... ......... 13 2.1.1 features ................................................................................................................. 13 2.1.2 address space....................................................................................................... 14 2.1.3 register configuration .......................................................................................... 14 2.2 register descriptions ...................................................................................................... ... 15 2.2.1 general registers .................................................................................................. 15 2.2.2 control registers................................................................................................... 15 2.2.3 initial register values........................................................................................... 16 2.3 data formats ............................................................................................................... ....... 17 2.3.1 data formats in general registers ....................................................................... 18 2.3.2 memory data formats .......................................................................................... 19 2.4 addressing modes........................................................................................................... ... 20 2.4.1 addressing modes................................................................................................. 20 2.4.2 effective address calculation............................................................................... 22 2.5 instruction set ............................................................................................................ ........ 26 2.5.1 data transfer instructions..................................................................................... 28 2.5.2 arithmetic operations........................................................................................... 30 2.5.3 logic operations................................................................................................... 31 2.5.4 shift operations .................................................................................................... 31 2.5.5 bit manipulations.................................................................................................. 33 2.5.6 branching instructions .......................................................................................... 37 2.5.7 system control instructions.................................................................................. 39 2.5.8 block data transfer instruction............................................................................ 40 2.6 basic operational timing .................................................................................................. 4 2 2.6.1 access to on-chip memory (ram, rom) ......................................................... 42 2.6.2 access to on-chip peripheral modules................................................................ 43 2.7 cpu states ................................................................................................................. ........ 45 2.7.1 overview............................................................................................................... 45 2.7.2 program execution state....................................................................................... 46 2.7.3 program halt state ................................................................................................ 46 2.7.4 exception-handling state ..................................................................................... 46
ii 2.8 memory map................................................................................................................. ..... 47 2.9 application notes.......................................................................................................... ..... 50 2.9.1 notes on data access ........................................................................................... 50 2.9.2 notes on bit manipulation .................................................................................... 52 2.9.3 notes on use of the eepmov instruction ........................................................... 58 section 3 exception handling ........................................................................................ 59 3.1 overview ................................................................................................................... ......... 59 3.2 reset...................................................................................................................... ............. 59 3.2.1 overview............................................................................................................... 59 3.2.2 reset sequence ..................................................................................................... 59 3.2.3 interrupt immediately after reset ......................................................................... 60 3.3 interrupts ................................................................................................................. ........... 61 3.3.1 overview............................................................................................................... 61 3.3.2 interrupt control registers ................................................................................... 63 3.3.3 external interrupts................................................................................................. 72 3.3.4 internal interrupts.................................................................................................. 73 3.3.5 interrupt operations .............................................................................................. 74 3.3.6 interrupt response time....................................................................................... 79 3.4 application notes.......................................................................................................... ..... 80 3.4.1 notes on stack area use ...................................................................................... 80 3.4.2 notes on rewriting port mode registers ............................................................. 81 3.4.3 notes on interrupt request flag clearing methods ............................................. 83 section 4 clock pulse generators ................................................................................. 85 4.1 overview ................................................................................................................... ......... 85 4.1.1 block diagram ...................................................................................................... 85 4.1.2 system clock and subclock.................................................................................. 85 4.2 system clock generator .................................................................................................... 8 6 4.3 subclock generator ......................................................................................................... ... 89 4.4 prescalers ................................................................................................................. .......... 91 4.5 note on oscillators........................................................................................................ ..... 92 4.5.1 definition of oscillation settling standby time .................................................. 92 4.5.2 notes on use of crystal oscillator element (excluding ceramic oscillator element) .............................................................. 94 section 5 power-down modes ....................................................................................... 95 5.1 overview ................................................................................................................... ......... 95 5.1.1 system control registers...................................................................................... 98 5.2 sleep mode................................................................................................................. ........ 103 5.2.1 transition to sleep mode ...................................................................................... 103 5.2.2 clearing sleep mode............................................................................................. 103 5.2.3 clock frequency in sleep (medium-speed) mode............................................... 104
iii 5.3 standby mode............................................................................................................... ...... 105 5.3.1 transition to standby mode.................................................................................. 105 5.3.2 clearing standby mode ........................................................................................ 105 5.3.3 oscillator settling time after standby mode is cleared ...................................... 105 5.3.4 standby mode transition and pin states .............................................................. 106 5.3.5 notes on external input signal changes before/after standby mode .................. 107 5.4 watch mode ................................................................................................................. ...... 109 5.4.1 transition to watch mode .................................................................................... 109 5.4.2 clearing watch mode ........................................................................................... 109 5.4.3 oscillator settling time after watch mode is cleared......................................... 109 5.4.4 notes on external input signal changes before/after watch mode..................... 109 5.5 subsleep mode .............................................................................................................. ..... 110 5.5.1 transition to subsleep mode ................................................................................ 110 5.5.2 clearing subsleep mode ....................................................................................... 110 5.6 subactive mode............................................................................................................. ..... 111 5.6.1 transition to subactive mode............................................................................... 111 5.6.2 clearing subactive mode...................................................................................... 111 5.6.3 operating frequency in subactive mode ............................................................. 111 5.7 active (medium-speed) mode........................................................................................... 112 5.7.1 transition to active (medium-speed) mode........................................................ 112 5.7.2 clearing active (medium-speed) mode............................................................... 112 5.7.3 operating frequency in active (medium-speed) mode ...................................... 112 5.8 direct transfer ............................................................................................................ ....... 113 5.8.1 overview of direct transfer................................................................................. 113 5.8.2 direct transition times ........................................................................................ 114 5.8.3 notes on external input signal changes before/after direct transition .............. 116 5.9 module standby mode....................................................................................................... 1 17 5.9.1 setting module standby mode ............................................................................. 117 5.9.2 clearing module standby mode........................................................................... 117 section 6 rom .................................................................................................................... 119 6.1 overview ................................................................................................................... ......... 119 6.1.1 block diagram ...................................................................................................... 119 6.2 prom mode .................................................................................................................. .... 120 6.2.1 setting to prom mode......................................................................................... 120 6.2.2 socket adapter pin arrangement and memory map ........................................... 120 6.3 programming ................................................................................................................ ...... 123 6.3.1 writing and verifying........................................................................................... 123 6.3.2 programming precautions..................................................................................... 128 6.4 reliability of programmed data ........................................................................................ 129 section 7 ram .................................................................................................................... 131 7.1 overview ................................................................................................................... ......... 131
iv 7.1.1 block diagram ...................................................................................................... 131 section 8 i/o ports ............................................................................................................. 133 8.1 overview ................................................................................................................... ......... 133 8.2 port 1 ..................................................................................................................... ............. 135 8.2.1 overview............................................................................................................... 13 5 8.2.2 register configuration and description ............................................................... 135 8.2.3 pin functions......................................................................................................... 140 8.2.4 pin states............................................................................................................... 142 8.2.5 mos input pull-up............................................................................................... 142 8.3 port 2 [chip internal i/o port] ........................................................................................... 1 43 8.3.1 overview............................................................................................................... 14 3 8.3.2 register configuration and description ............................................................... 143 8.3.3 function ................................................................................................................ 1 47 8.3.4 states ................................................................................................................... .. 147 8.4 port 3 ..................................................................................................................... ............. 148 8.4.1 overview............................................................................................................... 14 8 8.4.2 register configuration and description ............................................................... 148 8.4.3 pin functions......................................................................................................... 151 8.4.4 pin states............................................................................................................... 153 8.4.5 mos input pull-up............................................................................................... 153 8.5 port 4* .................................................................................................................... ............ 154 8.5.1 overview............................................................................................................... 15 4 8.5.2 register configuration and description ............................................................... 154 8.5.3 pin functions......................................................................................................... 156 8.5.4 pin states............................................................................................................... 157 8.6 port 5 ..................................................................................................................... ............. 158 8.6.1 overview............................................................................................................... 15 8 8.6.2 register configuration and description ............................................................... 158 8.6.3 pin functions......................................................................................................... 160 8.6.4 pin states............................................................................................................... 161 8.6.5 mos input pull-up............................................................................................... 161 8.7 port 6 ..................................................................................................................... ............. 162 8.7.1 overview............................................................................................................... 16 2 8.7.2 register configuration and description ............................................................... 162 8.7.3 pin functions......................................................................................................... 164 8.7.4 pin states............................................................................................................... 164 8.7.5 mos input pull-up............................................................................................... 164 8.8 port 7 ..................................................................................................................... ............. 165 8.8.1 overview............................................................................................................... 16 5 8.8.2 register configuration and description ............................................................... 165 8.8.3 pin functions......................................................................................................... 167 8.8.4 pin states............................................................................................................... 167
v 8.9 port 8 ..................................................................................................................... ............. 168 8.9.1 overview............................................................................................................... 16 8 8.9.2 register configuration and description ............................................................... 168 8.9.3 pin functions......................................................................................................... 169 8.9.4 pin states............................................................................................................... 169 8.10 port 9 .................................................................................................................... .............. 170 8.10.1 overview............................................................................................................... 1 70 8.10.2 register configuration and description ............................................................... 170 8.10.3 pin functions......................................................................................................... 17 2 8.10.4 pin states.............................................................................................................. . 172 8.11 port a .................................................................................................................... ............. 173 8.11.1 overview............................................................................................................... 1 73 8.11.2 register configuration and description ............................................................... 173 8.11.4 pin states.............................................................................................................. . 174 8.12 port b .................................................................................................................... ............. 175 8.12.1 overview............................................................................................................... 1 75 8.12.2 register configuration and description ............................................................... 175 8.13 input/output data inversion function ............................................................................... 176 8.13.1 overview............................................................................................................... 1 76 8.13.2 register configuration and descriptions .............................................................. 176 8.13.3 note on modification of serial port control register .......................................... 178 8.14 application note ........................................................................................................... ..... 178 8.14.1 the management of the un-use terminal ........................................................... 178 section 9 timers ................................................................................................................. 179 9.1 overview ................................................................................................................... ......... 179 9.2 timer a .................................................................................................................... .......... 180 9.2.1 overview............................................................................................................... 18 0 9.2.2 register descriptions ............................................................................................ 182 9.2.3 timer operation .................................................................................................... 186 9.2.4 timer a operation states ..................................................................................... 187 9.2.5 application note................................................................................................... 187 9.3 timer c .................................................................................................................... .......... 188 9.3.1 overview............................................................................................................... 18 8 9.3.2 register descriptions ............................................................................................ 190 9.3.3 timer operation .................................................................................................... 193 9.3.4 timer c operation states...................................................................................... 195 9.4 timer f.................................................................................................................... ........... 196 9.4.1 overview............................................................................................................... 19 6 9.4.2 register descriptions ............................................................................................ 199 9.4.3 cpu interface........................................................................................................ 206 9.4.4 operation............................................................................................................... 2 09 9.4.5 application notes ................................................................................................. 212
vi 9.5 timer g .................................................................................................................... .......... 215 9.5.1 overview............................................................................................................... 21 5 9.5.2 register descriptions ............................................................................................ 217 9.5.3 noise canceler ...................................................................................................... 221 9.5.4 operation............................................................................................................... 2 23 9.5.5 application notes ................................................................................................. 227 9.5.6 timer g application example .............................................................................. 232 9.6 watchdog timer............................................................................................................. .... 233 9.6.1 overview............................................................................................................... 23 3 9.6.2 register descriptions ............................................................................................ 234 9.6.3 timer operation .................................................................................................... 238 9.6.4 watchdog timer operation states ........................................................................ 239 section 10 serial communication interface ................................................................. 241 10.1 overview .................................................................................................................. .......... 241 10.2 sci1 [chip internal function] ........................................................................................... 24 2 10.2.1 overview............................................................................................................... 2 42 10.2.2 register descriptions ............................................................................................ 244 10.2.3 operation............................................................................................................... 250 10.2.4 interrupt source..................................................................................................... 252 10.2.5 application note................................................................................................... 253 10.3 sci3 ...................................................................................................................... ............. 254 10.3.1 overview............................................................................................................... 2 54 10.3.2 register descriptions ............................................................................................ 258 10.3.3 operation............................................................................................................... 280 10.3.4 interrupts .............................................................................................................. . 308 10.3.5 application notes ................................................................................................. 309 section 11 a/d converter .................................................................................................. 315 11.1 overview .................................................................................................................. .......... 315 11.1.1 features ................................................................................................................ . 315 11.1.2 block diagram ...................................................................................................... 316 11.1.3 pin configuration .................................................................................................. 317 11.1.4 register configuration .......................................................................................... 317 11.2 register descriptions ..................................................................................................... .... 318 11.2.1 a/d result registers (adrrh, adrrl) ........................................................... 318 11.2.2 a/d mode register (amr) .................................................................................. 318 11.2.3 a/d start register (adsr)................................................................................... 320 11.2.4 clock stop register 1 (ckstpr1)....................................................................... 321 11.3 operation ................................................................................................................. ........... 322 11.3.1 a/d conversion operation ................................................................................... 322 11.3.2 start of a/d conversion by external trigger input ............................................. 322 11.3.3 a/d converter operation modes .......................................................................... 323
vii 11.4 interrupts ................................................................................................................ ............ 323 11.5 typical use ............................................................................................................... ......... 323 11.6 application notes......................................................................................................... ...... 327 section 12 flex roaming decoder ii ..................................................................... 329 12.1 overview .................................................................................................................. .......... 329 12.1.1 features ................................................................................................................ . 329 12.1.2 system block diagram ......................................................................................... 330 12.1.3 functional block diagram .................................................................................... 332 12.2 spi packets............................................................................................................... ............. 333 12.2.1 packet communication initiated by the host ....................................................... 333 12.2.2 packet communication initiated by the flex decoder ....................................... 334 12.2.3 host-to-decoder packet map................................................................................ 336 12.2.4 decoder-to-host packet map................................................................................ 338 12.3 host-to-decoder packet descriptions ................................................................................ 338 12.3.1 checksum packet .................................................................................................. 338 12.3.2 configuration packet............................................................................................. 341 12.3.3 control packet....................................................................................................... 344 12.3.4 all frame mode packet ........................................................................................ 345 12.3.5 operator messaging address enable packet ........................................................ 347 12.3.6 roaming control packet ....................................................................................... 347 12.3.7 timing control packet .......................................................................................... 350 12.3.8 receiver line control packet ............................................................................... 351 12.3.9 receiver control configuration packets............................................................... 351 12.3.10 frame assignment packets ................................................................................... 355 12.3.11 user address enable packet ................................................................................. 356 12.3.12 user address assignment packets........................................................................ 357 12.4 decoder-to-host packet descriptions ................................................................................ 358 12.4.1 block information word packet ........................................................................... 359 12.4.2 address packet ...................................................................................................... 360 12.4.3 vector packet ........................................................................................................ 361 12.4.4 message packet..................................................................................................... 366 12.4.5 roaming status packet ......................................................................................... 366 12.4.6 receiver shutdown packet ................................................................................... 369 12.4.7 status packet ......................................................................................................... 37 0 12.4.8 part id packet ....................................................................................................... 372 12.5 application notes......................................................................................................... ...... 374 12.5.1 receiver control ................................................................................................... 374 12.5.2 message building.................................................................................................. 377 12.5.3 building a fragmented message........................................................................... 379 12.5.4 operation of a temporary address....................................................................... 382 12.5.5 using the receiver shutdown packet ................................................................... 384 12.6 timing diagrams (reference data) ................................................................................... 387
viii 12.6.1 spi timing ............................................................................................................ 38 7 12.6.2 start-up timing..................................................................................................... 389 12.6.3 reset timing......................................................................................................... 390 section 13 electrical characteristics ............................................................................... 391 13.1 absolute maximum ratings............................................................................................... 391 13.2 electrical characteristics................................................................................................ .... 392 13.2.1 power supply voltage and operating range ....................................................... 392 13.2.2 dc characteristics ................................................................................................ 394 13.2.3 ac characteristics ................................................................................................ 398 13.2.4 a/d converter characteristics .............................................................................. 401 13.3 operation timing .......................................................................................................... ..... 402 13.4 output load circuit ....................................................................................................... .... 405 13.5 resonator equivalent circuit ............................................................................................. 4 05 13.6 usage note ................................................................................................................ ......... 406 appendix a cpu instruction set ..................................................................................... 407 a.1 instructions................................................................................................................ ......... 407 a.2 operation code map .......................................................................................................... 415 a.3 number of execution states............................................................................................... 417 appendix b internal i/o registers .................................................................................. 423 b.1 addresses ................................................................................................................... ........ 423 b.2 functions ................................................................................................................... ......... 426 appendix c i/o port block diagrams ........................................................................... 478 c.1 block diagrams of port 1................................................................................................... 478 c.2 block diagrams of port 2 [chip internal i/o port] ............................................................ 482 c.3 block diagrams of port 3................................................................................................... 486 c.4 block diagrams of port 4................................................................................................... 493 c.5 block diagram of port 5 .................................................................................................... 497 c.6 block diagram of port 6 .................................................................................................... 498 c.7 block diagram of port 7 .................................................................................................... 499 c.8 block diagrams of port 8................................................................................................... 500 c.9 block diagram of port 9 .................................................................................................... 501 c.10 block diagram of port a ................................................................................................... 502 c.11 block diagram of port b ................................................................................................... 503 appendix d port states in the different processing states ..................................... 504 appendix e list of product codes .................................................................................. 505 appendix f package dimensions .................................................................................... 506
1 section 1 overview 1.1 overview the h8/300l series is a series of single-chip microcomputers (mcu: microcomputer unit), built around the high-speed h8/300l cpu and equipped with peripheral system functions on-chip. the h8/3937 and h8/3937r series are h8/300l series microcomputers with an on-chip flex decoder. with on-chip peripheral functions including a flex decoder, five kinds of timers, a 2-channel serial communication interface, and an a/d converter, the configuration of these series makes them ideal for use as embedded microcomputers in pagers using the flex system, which require low power consumption. models in the h8/3937 series and h8/3937r series are the h8/3935 and h8/3935r, with on-chip 40-kbyte rom and 2-kbyte ram, the h8/3936 and h8/3936r, with on-chip 48-kbyte rom and 2-kbyte ram, and the h8/3937 and h8/3937r, with on-chip 60-kbyte rom and 2-kbyte ram. the h8/3937 and h8/3937r series are also available in a ztat* version with on-chip prom which can be programmed as required by the user. the h8/3937 series supports non-roaming, while the h8/3937r series supports roaming. table 1-1 summarizes the features of the h8/3937 series and h8/3937r series. note: * ztat (zero turn around time) is a trademark of hitachi, ltd.
2 table 1-1 features item description cpu high-speed h8/300l cpu ? general-register architecture general registers: sixteen 8-bit registers (can be used as eight 16-bit registers) ? operating speed ? max. operating speed: 5 mhz ? add/subtract: 0.4 ? (operating at 5 mhz) ? multiply/divide: 2.8 ? (operating at 5 mhz) ? can run on 76.8 khz or 160 khz subclock ? instruction set compatible with h8/300 cpu ? instruction length of 2 bytes or 4 bytes ? basic arithmetic operations between registers ? mov instruction for data transfer between memory and registers ? typical instructions ? multiply (8 bits 8 bits) ? divide (16 bits 8 bits) ? bit accumulator ? register-indirect designation of bit position interrupts 36 interrupt sources ? 12 external interrupt sources (irq4 to irq1, wkp7 to wkp0) ? 23 internal interrupt sources ? 1 internal irq0 interrupt source (irq0) clock pulse generators two on-chip clock pulse generators ? system clock pulse generator: 2 to 10 mhz ? subclock pulse generator: 160 khz, 76.8 khz power-down modes seven power-down modes ? sleep (high-speed) mode ? sleep (medium-speed) mode ? standby mode ? watch mode ? subsleep mode ? subactive mode ? active (medium-speed) mode
3 item description memory large on-chip memory ? h8/3935, h8/3935r: 40-kbyte rom, 2-kbyte ram ? h8/3936, h8/3936r: 48-kbyte rom, 2-kbyte ram ? h8/3937, h8/3937r: 60-kbyte rom, 2-kbyte ram i/o ports 67 pins ? 59 i/o pins ? 8 input pins ? 5 internal i/o ? 1 internal input timers five on-chip timers ? timer a: 8-bit timer count-up timer with selection of eight internal clock signals divided from the system clock (? * and four clock signals divided from the watch clock (?) * ? timer c: 8-bit timer ? count-up/down timer with selection of seven internal clock signals or event input from external pin ? auto-reloading ? timer f: 16-bit timer ? can be used as two independent 8-bit timers ? count-up timer with selection of four internal clock signals or event input from external pin ? provision for toggle output by means of compare-match function ? timer g: 8-bit timer ? count-up timer with selection of four internal clock signals ? incorporates input capture function (built-in noise canceler) ? watchdog timer ? reset signal generated by overflow of 8-bit counter serial communication interface two serial communication interface channels on chip internal serial communication interface function ? sci1: synchronous serial interface 8-bit or 16-bit transfer data can be selected used for interface to on-chip flex decoder ? sci31: 8-bit synchronous/asynchronous serial interface incorporates multiprocessor communication function ? sci32: 8-bit synchronous/asynchronous serial interface incorporates multiprocessor communication function
4 item description a/d converter successive approximations using a resistance ladder ? 8-channel analog input pins ? conversion time: 31/?or 62/? per channel flex decoder ii on-chip flex decoder ii ? conforms to flex protocol revision 1.9 ? decoding capability: 1600, 3200, 6400 bits/second ? decoding phase: any-phase, single-phase product lineup product code specification mask rom version ztat version package rom/ram size (byte) non-roaming hd6433935x 100-pin tqfp (tfp-100b) 40 k/2 k hd6433935w 100-pin tqfp (tfp-100g) hd6433936x 100-pin tqfp (tfp-100b) 48 k/2 k hd6433936w 100-pin tqfp (tfp-100g) hd6433937x hd6473937x 100-pin tqfp (tfp-100b) 60 k/2 k hd6433937w hd6473937w 100-pin tqfp (tfp-100g) roaming hd6433935rx 100-pin tqfp (tfp-100b) 40 k/2 k hd6433935rw 100-pin tqfp (tfp-100g) hd6433936rx 100-pin tqfp (tfp-100b) 48 k/2 k hd6433936rw 100-pin tqfp (tfp-100g) hd6433937rx hd6473937rx 100-pin tqfp (tfp-100b) 60 k/2 k hd6433937rw hd6473937rw 100-pin tqfp (tfp-100g) note: * see section 4, clock pulse generator, for the definition of ?and ?.
5 1.2 internal block diagram figure 1-1 shows a block diagram of the h8/3937 series and h8/3937r series. p1 0 /tmow p1 1 /tmofl p1 2 /tmofh p1 3 /tmig p1 4 / irq adtrg irq irq irq reso wkp wkp wkp wkp wkp wkp wkp wkp irq ready ss reset res decoder incorporated in the chip. internal functions flex decoder figure 1-1 block diagram
6 1.3 pin arrangement and functions 1.3.1 pin arrangement the h8/3937 series and h8/3937r series pin arrangement is shown in figure 1-2. s6 s7 symclk exts0 exts1 lobat test24 test23 test22 test21 test20 test43 p42/txd32 p41/rxd32 p40/sck32 p77 p76 p75 p74 p73 p72 p71 p70 v cc v ss pb1/an1 pb2/an2 pb3/an3 pb4/an4 pb5/an5 pb6/an6 pb7/an7 av ss osc2 osc1 v ss v cc res irq4 adtrg irq1 irq2 irq3 wkp7 wkp6 wkp5 wkp4 wkp3 wkp2 wkp1 wkp0 reso figure 1-2 pin arrangement (tfp-100b and tfp-100g: top view)
7 1.3.2 pin functions table 1-2 outlines the pin functions of the h8/3937 series and h8/3937r series. table 1-2 pin functions pin no. type symbol tfp-100b tfp-100g i/o name and functions power source pins v cc 12 52 input power supply: all v cc pins should be connected to the system power supply. v ss 11 51 input ground: all v ss pins should be connected to the system power supply (0 v). av cc 99 input analog power supply: this is the power supply pin for the a/d converter. when the a/d converter is not used, connect this pin to the system power supply. av ss 8 input analog ground: this is the a/d converter ground pin. it should be connected to the system power supply (0v). clock pins osc 1 10 input these pins connect to a crystal or osc 2 9 output ceramic oscillator, or can be used to input an external clock. see section 4, clock pulse generators, for a typical connection diagram. dx 1 85 input these pins connect to a 76.8-khz or dx 2 84 160-khz crystal oscillator. output see section 4, clock pulse generators, for a typical connection diagram. system control res reset: when this pin is driven low, the chip is reset reso reset output: outputs the cpu internal reset signal. test testd testa9h 86 83 34 input test pins: these pins are reserved and cannot be used. they should be connected to v ss . test20 to test24 test43 65 to 69 64 output test pins: these pins are reserved and cannot be used. they should be left open.
8 pin no. type symbol tfp-100b tfp-100g i/o name and functions interrupt pins irq irq irq irq irq interrupt request 0 and 1: these are input pins for edge-sensitive external interrupts, with a selection of rising or falling edge. wkp wkp wakeup interrupt request 0 to 7: these are input pins for rising or falling- edge- sensitive external interrupts. internal irq 0 interrupt pin irq 0 input internal interrupt request 0: this is the request pin for an edge-sensistive internal interrupt, with a selection of rising or falling edge. timer pins tmow 14 output clock output: this is an output pin for waveforms generated by the timer a output circuit. tmic 19 input timer c event input: this is an event input pin for input to the timer c counter. ud 27 input timer c up/down select: this pin selects up- or down-counting for the timer c counter. the counter operates as a down- counter when this pin is high, and as an up- counter when low. tmif 21 input timer f event input: this is an event input pin for input to the timer f counter. tmofl 15 output timer fl output: this is an output pin for waveforms generated by the timer fl output compare function. tmofh 16 output timer fh output: this is an output pin for waveforms generated by the timer fh output compare function. tmig 17 input timer g capture input: this is an input pin for timer g input capture. i/o ports pb 7 to pb 0 7 to 1, 100 input port b: this is an 8-bit input port. p4 2 to p4 0 63 to 61 i/o port 4 (bits 2 to 0): this is a 3-bit i/o port. input or output can be designated for each bit by means of port control register 4 (pcr4).
9 pin no. type symbol tfp-100b tfp-100g i/o name and functions i/o ports pa 3 to pa 0 25 to 22 i/o port a: this is a 4-bit i/o port. input or output can be designated for each bit by means of port control register a (pcra). p1 7 to p1 0 21 to 14 i/o port 1: this is an 8-bit i/o port. input or output can be designated for each bit by means of port control register 1 (pcr1). p3 7 to p3 0 33 to 26 i/o port 3: this is an 8-bit i/o port. input or output can be designated for each bit by means of port control register 3 (pcr3). p5 7 to p5 0 42 to 35 i/o port 5: this is an 8-bit i/o port. input or output can be designated for each bit by means of port control register 5 (pcr5). p6 7 to p6 0 50 to 43 i/o port 6: this is an 8-bit i/o port. input or output can be designated for each bit by means of port control register 6 (pcr6). p7 7 to p7 0 60 to 53 i/o port 7: this is an 8-bit i/o port. input or output can be designated for each bit by means of port control register 7 (pcr7). p8 7 to p8 0 94 to 87 i/o port 8: this is an 8-bit i/o port. input or output can be designated for each bit by means of port control register 8 (pcr8). p9 3 to p9 0 98 to 95 i/o port 9: this is a 4-bit i/o port. input or output can be designated for each bit by means of port control register 9 (pcr9). internal i/o ports p4 3 input port 4 (bit 3): this is an internal 1-bit input port. p2 4 to p2 0 i/o port 2: this is an internal 5-bit i/o port. input or output can be designated for each bit by means of port control register 2 (pcr2). serial communi- rxd 31 30 input sci31 receive data input: this is the sci31 data input pin. cation interface txd 31 31 output sci31 transmit data output: this is the sci31 data output pin. (sci) sck 31 29 i/o sci31 clock i/o: this is the sci31 clock i/o pin.
10 pin no. type symbol tfp-100b tfp-100g i/o name and functions serial communi- rxd 32 62 input sci32 receive data input: this is the sci32 data input pin. cation interface txd 32 63 output sci32 transmit data output: this is the sci32 data output pin. (sci) sck 32 61 i/o sci32 clock i/o: this is the sci32 clock i/o pin. internal serial communi- si 1 input sci1 receive data input: this is the sci1 data input pin. cation interface so 1 output sci1 transmit data output: this is the sci1 data output pin (sci) sck 1 i/o sci1 clock i/o: this is the sci1 clock i/o pin. a/d converter an 7 to an 0 7 to 1, 100 input analog input channels 7 to 0: these are analog data input channels to the a/d converter adtrg a/d converter trigger input: this is the external trigger input pin to the a/d converter flex decoder ii reset input decoder reset: a reset is executed when this pin goes low. exts1 71 input decode symbol input: msb of the symbol currently being decoded. exts0 72 input decode symbol input: lsb of the symbol currently being decoded. lobat 70 input voltage drop detection input: input pin for the voltage drop detection signal. ss input spi mode select: slave mode is selected when this pin goes low. sck input spi clock input: spi clock input. mosi input spi receive data input: spi data input. miso output spi transmit data output: spi data output. ready output ready pin: goes low when the spi is ready to transmit/receive.
11 pin no. type symbol tfp-100b tfp-100g i/o name and functions flex decoder ii clkout 82 output clock output: 38.4 khz or 40 khz clock output (derived from on-chip crystal oscillator). symclk 73 output symbol clock output: recovered symbol clock pin. s0 81 output receiver control output: receiver control signal output pin (when using external demodulator). s1 to s7 80 to 74 output receiver control output: three-state receiver control signal output. ifin 81 input if signal input: limited if signal input pin (when using internal demodulator).
12
13 section 2 cpu 2.1 overview the h8/300l cpu has sixteen 8-bit general registers, which can also be paired as eight 16-bit registers. its concise instruction set is designed for high-speed operation. 2.1.1 features features of the h8/300l cpu are listed below. ? general-register architecture sixteen 8-bit general registers, also usable as eight 16-bit general registers ? instruction set with 55 basic instructions, including: ? multiply and divide instructions ? powerful bit-manipulation instructions ? eight addressing modes ? register direct ? register indirect ? register indirect with displacement ? register indirect with post-increment or pre-decrement ? absolute address ? immediate ? program-counter relative ? memory indirect ? 64-kbyte address space ? high-speed operation ? all frequently used instructions are executed in two to four states ? high-speed arithmetic and logic operations ? 8- or 16-bit register-register add or subtract: 0.4 ?* ? 8 8-bit multiply: 2.8 ?* ? 16 ?8-bit divide: 2.8 ?* ? low-power operation modes sleep instruction for transfer to low-power operation note: * these values are at ?= 5 mhz.
14 2.1.2 address space the h8/300l cpu supports an address space of up to 64 kbytes for storing program code and data. see 2.8, memory map, for details of the memory map. 2.1.3 register configuration figure 2-1 shows the register structure of the h8/300l cpu. there are two groups of registers: the general registers and control registers. 7070 15 0 pc r0h r1h r2h r3h r4h r5h r6h r7h r0l r1l r2l r3l r4l r5l r6l r7l (sp) sp: stack pointer pc: program counter ccr: condition code register carry flag overflow flag zero flag negative flag half-carry flag interrupt mask bit user bit user bit ccr i u h u n z v c general registers (rn) control registers (cr) 753210 64 figure 2-1 cpu registers
15 2.2 register descriptions 2.2.1 general registers all the general registers can be used as both data registers and address registers. when used as data registers, they can be accessed as 16-bit registers (r0 to r7), or the high bytes (r0h to r7h) and low bytes (r0l to r7l) can be accessed separately as 8-bit registers. when used as address registers, the general registers are accessed as 16-bit registers (r0 to r7). r7 also functions as the stack pointer (sp), used implicitly by hardware in exception processing and subroutine calls. when it functions as the stack pointer, as indicated in figure 2-2, sp (r7) points to the top of the stack. lower address side [h'0000] upper address side [h'ffff] unused area stack area sp (r7) figure 2-2 stack pointer 2.2.2 control registers the cpu control registers include a 16-bit program counter (pc) and an 8-bit condition code register (ccr). program counter (pc): this 16-bit register indicates the address of the next instruction the cpu will execute. all instructions are fetched 16 bits (1 word) at a time, so the least significant bit of the pc is ignored (always regarded as 0). condition code register (ccr): this 8-bit register contains internal status information, including the interrupt mask bit (i) and half-carry (h), negative (n), zero (z), overflow (v), and carry (c) flags. these bits can be read and written by software (using the ldc, stc, andc, orc, and xorc instructions). the n, z, v, and c flags are used as branching conditions for conditional branching (bcc) instructions.
16 bit 7?nterrupt mask bit (i): when this bit is set to 1, interrupts are masked. this bit is set to 1 automatically at the start of exception handling. the interrupt mask bit may be read and written by software. for further details, see section 3.3, interrupts. bit 6?ser bit (u): can be used freely by the user. bit 5?alf-carry flag (h): when the add.b, addx.b, sub.b, subx.b, cmp.b, or neg.b instruction is executed, this flag is set to 1 if there is a carry or borrow at bit 3, and is cleared to 0 otherwise. the h flag is used implicitly by the daa and das instructions. when the add.w, sub.w, or cmp.w instruction is executed, the h flag is set to 1 if there is a carry or borrow at bit 11, and is cleared to 0 otherwise. bit 4?ser bit (u): can be used freely by the user. bit 3?egative flag (n): indicates the most significant bit (sign bit) of the result of an instruction. bit 2?ero flag (z): set to 1 to indicate a zero result, and cleared to 0 to indicate a non-zero result. bit 1?verflow flag (v): set to 1 when an arithmetic overflow occurs, and cleared to 0 at other times. bit 0?arry flag (c): set to 1 when a carry occurs, and cleared to 0 otherwise. used by: ? add instructions, to indicate a carry ? subtract instructions, to indicate a borrow ? shift and rotate instructions, to store the value shifted out of the end bit the carry flag is also used as a bit accumulator by bit manipulation instructions. some instructions leave some or all of the flag bits unchanged. refer to the h8/300l series programming manual for the action of each instruction on the flag bits. 2.2.3 initial register values when the cpu is reset, the program counter (pc) is initialized to the value stored at address h'0000 in the vector table, and the i bit in the ccr is set to 1. the other ccr bits and the general registers are not initialized. in particular, the stack pointer (r7) is not initialized. the stack pointer should be initialized by software, by the first instruction executed after a reset.
17 2.3 data formats the h8/300l cpu can process 1-bit data, 4-bit (bcd) data, 8-bit (byte) data, and 16-bit (word) data. ? bit manipulation instructions operate on 1-bit data specified as bit n in a byte operand (n = 0, 1, 2, ..., 7). ? all arithmetic and logic instructions except adds and subs can operate on byte data. ? the mov.w, add.w, sub.w, cmp.w, adds, subs, mulxu (8 bits 8 bits), and divxu (16 bits ?8 bits) instructions operate on word data. ? the daa and das instructions perform decimal arithmetic adjustments on byte data in packed bcd form. each nibble of the byte is treated as a decimal digit.
18 2.3.1 data formats in general registers data of all the sizes above can be stored in general registers as shown in figure 2-3. 7 6 5 4 3 2 1 0 don? care data type register no. data format 70 1-bit data rnh 76543210 don? care 70 1-bit data rnl msb lsb don? care 70 byte data rnh byte data rnl word data rn 4-bit bcd data rnh 4-bit bcd data rnl notation: rnh: rnl: msb: lsb: upper byte of general register lower byte of general register most significant bit least significant bit msb lsb don? care 70 msb lsb 15 0 upper digit lower digit don? care 70 3 4 don? care upper digit lower digit 70 3 4 figure 2-3 register data formats
19 2.3.2 memory data formats figure 2-4 indicates the data formats in memory. the h8/300l cpu can access word data stored in memory (mov.w instruction), but the word data must always begin at an even address. if word data starting at an odd address is accessed, the least significant bit of the address is regarded as 0, and the word data starting at the preceding address is accessed. the same applies to instruction codes. data format 76543210 address data type 70 address n msb lsb msb lsb upper 8 bits lower 8 bits msb lsb ccr ccr * msb lsb msb lsb address n even address odd address even address odd address even address odd address 1-bit data byte data word data byte data (ccr) on stack word data on stack ccr: condition code register note: ignored on return * figure 2-4 memory data formats when the stack is accessed using r7 as an address register, word access should always be performed. when the ccr is pushed on the stack, two identical copies of the ccr are pushed to make a complete word. when they are restored, the lower byte is ignored.
20 2.4 addressing modes 2.4.1 addressing modes the h8/300l cpu supports the eight addressing modes listed in table 2-1. each instruction uses a subset of these addressing modes. table 2-1 addressing modes no. address modes symbol 1 register direct rn 2 register indirect @rn 3 register indirect with displacement @(d:16, rn) 4 register indirect with post-increment @rn+ register indirect with pre-decrement @ rn 5 absolute address @aa:8 or @aa:16 6 immediate #xx:8 or #xx:16 7 program-counter relative @(d:8, pc) 8 memory indirect @@aa:8 1. register direct?n: the register field of the instruction specifies an 8- or 16-bit general register containing the operand. only the mov.w, add.w, sub.w, cmp.w, adds, subs, mulxu (8 bits 8 bits), and divxu (16 bits 8 bits) instructions have 16-bit operands. 2. register indirect?rn: the register field of the instruction specifies a 16-bit general register containing the address of the operand in memory. 3. register indirect with displacement?(d:16, rn): the instruction has a second word (bytes 3 and 4) containing a displacement which is added to the contents of the specified general register to obtain the operand address in memory. this mode is used only in mov instructions. for the mov.w instruction, the resulting address must be even. 4. register indirect with post-increment or pre-decrement?rn+ or @?n: ? register indirect with post-increment @rn+ the @rn+ mode is used with mov instructions that load registers from memory.
21 the register field of the instruction specifies a 16-bit general register containing the address of the operand. after the operand is accessed, the register is incremented by 1 for mov.b or 2 for mov.w. for mov.w, the original contents of the 16-bit general register must be even. ? register indirect with pre-decrement @ rn the @ rn mode is used with mov instructions that store register contents to memory. the register field of the instruction specifies a 16-bit general register which is decremented by 1 or 2 to obtain the address of the operand in memory. the register retains the decremented value. the size of the decrement is 1 for mov.b or 2 for mov.w. for mov.w, the original contents of the register must be even. 5. absolute address?aa:8 or @aa: 16: the instruction specifies the absolute address of the operand in memory. the absolute address may be 8 bits long (@aa:8) or 16 bits long (@aa:16). the mov.b and bit manipulation instructions can use 8-bit absolute addresses. the mov.b, mov.w, jmp, and jsr instructions can use 16-bit absolute addresses. for an 8-bit absolute address, the upper 8 bits are assumed to be 1 (h'ff). the address range is h'ff00 to h'ffff (65280 to 65535). 6. immediate?xx:8 or #xx:16: the instruction contains an 8-bit operand (#xx:8) in its second byte, or a 16-bit operand (#xx:16) in its third and fourth bytes. only mov.w instructions can contain 16-bit immediate values. the adds and subs instructions implicitly contain the value 1 or 2 as immediate data. some bit manipulation instructions contain 3-bit immediate data in the second or fourth byte of the instruction, specifying a bit number. 7. program-counter relative?(d:8, pc): this mode is used in the bcc and bsr instructions. an 8-bit displacement in byte 2 of the instruction code is sign-extended to 16 bits and added to the program counter contents to generate a branch destination address. the possible branching range is 126 to +128 bytes ( 63 to +64 words) from the current address. the displacement should be an even number. 8. memory indirect?@aa:8: this mode can be used by the jmp and jsr instructions. the second byte of the instruction code specifies an 8-bit absolute address. the word located at this address contains the branch destination address. the upper 8 bits of the absolute address are assumed to be 0 (h'00), so the address range is from h'0000 to h'00ff (0 to 255). note that with the h8/300l series, the lower end of the address area is also used as a vector area. see 3.3, interrupts, for details on the vector area.
22 if an odd address is specified as a branch destination or as the operand address of a mov.w instruction, the least significant bit is regarded as 0, causing word access to be performed at the address preceding the specified address. see 2.3.2, memory data formats, for further information. 2.4.2 effective address calculation table 2-2 shows how effective addresses are calculated in each of the addressing modes. arithmetic and logic instructions use register direct addressing (1). the add.b, addx, subx, cmp.b, and, or, and xor instructions can also use immediate addressing (6). data transfer instructions can use all addressing modes except program-counter relative (7) and memory indirect (8). bit manipulation instructions can use register direct (1), register indirect (2), or 8-bit absolute addressing (5) to specify the operand. register indirect (1) (bset, bclr, bnot, and btst instructions) or 3-bit immediate addressing (6) can be used independently to specify a bit position in the operand.
23 table 2-2 effective address calculation addressing mode and instruction format op rm 76 3 40 15 no. effective address calculation method effective address (ea) 1 register direct, rn operand is contents of registers indicated by rm/rn register indirect, @rn contents (16 bits) of register indicated by rm 0 15 register indirect with displacement, @(d:16, rn) op rm rn 87 3 40 15 op rm 76 3 40 15 disp op rm 76 3 40 15 register indirect with post-increment, @rn+ op rm 76 3 40 15 register indirect with pre-decrement, @ rn 2 3 4 incremented or decremented by 1 if operand is byte size, and by 2 if word size 0 15 disp 0 15 0 15 0 15 1 or 2 0 15 0 15 1 or 2 0 15 rm 30 rn 30 contents (16 bits) of register indicated by rm contents (16 bits) of register indicated by rm contents (16 bits) of register indicated by rm
24 addressing mode and instruction format no. effective address calculation method effective address (ea) 5 absolute address @aa:8 operand is 1- or 2-byte immediate data @aa:16 op 87 0 15 op 0 15 imm op disp 70 15 program-counter relative @(d:8, pc) 6 7 0 15 pc contents 0 15 0 15 abs h'ff 87 0 15 0 15 abs op #xx:16 op 87 0 15 imm immediate #xx:8 8 sign extension disp
25 addressing mode and instruction format no. effective address calculation method effective address (ea) 8 memory indirect, @@aa:8 op 87 0 15 memory contents (16 bits) 0 15 abs h'00 87 0 15 notation: rm, rn: op: disp: imm: abs: register field operation field displacement immediate data absolute address abs
26 2.5 instruction set the h8/300l series can use a total of 55 instructions, which are grouped by function in table 2-3. table 2-3 instruction set function instructions number data transfer mov, push * 1 , pop * 1 1 arithmetic operations add, sub, addx, subx, inc, dec, adds, subs, daa, das, mulxu, divxu, cmp, neg 14 logic operations and, or, xor, not 4 shift shal, shar, shll, shlr, rotl, rotr, rotxl, rotxr 8 bit manipulation bset, bclr, bnot, btst, band, biand, bor, bior, bxor, bixor, bld, bild, bst, bist 14 branch bcc * 2 , jmp, bsr, jsr, rts 5 system control rte, sleep, ldc, stc, andc, orc, xorc, nop 8 block data transfer eepmov 1 total: 55 notes: 1. push rn is equivalent to mov.w rn, @ sp. pop rn is equivalent to mov.w @sp+, rn. the same applies to the machine language. 2. bcc is a conditional branch instruction in which cc represents a condition code. the following sections give a concise summary of the instructions in each category, and indicate the bit patterns of their object code. the notation used is defined next.
27 notation rd general register (destination) rs general register (source) rn general register (ead), destination operand (eas), source operand ccr condition code register n n (negative) flag of ccr z z (zero) flag of ccr v v (overflow) flag of ccr c c (carry) flag of ccr pc program counter sp stack pointer #imm immediate data disp displacement + addition subtraction
28 2.5.1 data transfer instructions table 2-4 describes the data transfer instructions. figure 2-5 shows their object code formats. table 2-4 data transfer instructions instruction size * function mov b/w (eas) rn, and @rn+ addressing modes are available for word data. the @aa:8 addressing mode is available for byte data only. the @ r7 and @r7+ modes require word operands. do not specify byte size for these two modes. pop w @sp+ sp pushes a 16-bit general register onto the stack. equivalent to mov.w rn, @ sp. notes: * size: operand size b: byte w: word certain precautions are required in data access. see 2.9.1, notes on data access, for details.
29 15 0 87 op rm rn mov rm rm 15 0 87 op rn abs @aa:8 sp figure 2-5 data transfer instruction codes
30 2.5.2 arithmetic operations table 2-5 describes the arithmetic instructions. table 2-5 arithmetic instructions instruction size * function add sub b/w rd ?rs rs 8-bit unsigned division on data in two general registers, providing an 8-bit quotient and 8-bit remainder cmp b/w rd rs, rd #imm compares data in a general register with data in another general register or with immediate data, and indicates the result in the ccr. word data can be compared only between two general registers. neg b 0 rd s complement (arithmetic complement) of data in a general register notes: * size: operand size b: byte w: word
31 2.5.3 logic operations table 2-6 describes the four instructions that perform logic operations. table 2-6 logic operation instructions instruction size * function and b rd s complement (logical complement) of general register contents notes: * size: operand size b: byte 2.5.4 shift operations table 2-7 describes the eight shift instructions. table 2-7 shift instructions instruction size * function shal shar b rd shift * size: operand size b: byte
32 figure 2-6 shows the instruction code format of arithmetic, logic, and shift instructions. 15 0 87 op rm rn add, sub, cmp, addx, subx (rm) notation: op: rm, rn: imm: operation field register field immediate data 15 0 87 op rn adds, subs, inc, dec, daa, das, neg, not 15 0 87 op rn mulxu, divxu rm 15 0 87 rn imm add, addx, subx, cmp (#xx:8) op 15 0 87 op rn and, or, xor (rm) rm 15 0 87 rn imm and, or, xor (#xx:8) op 15 0 87 rn shal, shar, shll, shlr, rotl, rotr, rotxl, rotxr op figure 2-6 arithmetic, logic, and shift instruction codes
33 2.5.5 bit manipulations table 2-8 describes the bit-manipulation instructions. figure 2-7 shows their object code formats. table 2-8 bit-manipulation instructions instruction size * function bset b 1 * size: operand size b: byte
34 instruction size * function bxor b c * size: operand size b: byte certain precautions are required in bit manipulation. see 2.9.2, notes on bit manipulation, for details.
35 15 0 87 op imm rn operand: bit no.: notation: op: rm, rn: abs: imm: operation field register field absolute address immediate data 15 0 87 op rn bset, bclr, bnot, btst register direct (rn) immediate (#xx:3) operand: bit no.: register direct (rn) register direct (rm) rm 15 0 87 op 0 operand: bit no.: register indirect (@rn) immediate (#xx:3) rn 0 0 0 0 0 0 0 imm 15 0 87 op 0 operand: bit no.: register indirect (@rn) register direct (rm) rn 0 0 0 0 0 0 0 rm op 15 0 87 op operand: bit no.: absolute (@aa:8) immediate (#xx:3) abs 0000 imm op op 15 0 87 op operand: bit no.: absolute (@aa:8) register direct (rm) abs 0000 rm op 15 0 87 op imm rn operand: bit no.: register direct (rn) immediate (#xx:3) band, bor, bxor, bld, bst 15 0 87 op 0 operand: bit no.: register indirect (@rn) immediate (#xx:3) rn 0 0 0 0 0 0 0 imm op 15 0 87 op operand: bit no.: absolute (@aa:8) immediate (#xx:3) abs 0000 imm op figure 2-7 bit manipulation instruction codes
36 notation: op: rm, rn: abs: imm: operation field register field absolute address immediate data 15 0 87 op imm rn operand: bit no.: register direct (rn) immediate (#xx:3) biand, bior, bixor, bild, bist 15 0 87 op 0 operand: bit no.: register indirect (@rn) immediate (#xx:3) rn 0 0 0 0 0 0 0 imm op 15 0 87 op operand: bit no.: absolute (@aa:8) immediate (#xx:3) abs 0000 imm op figure 2-7 bit manipulation instruction codes (cont)
37 2.5.6 branching instructions table 2-9 describes the branching instructions. figure 2-8 shows their object code formats. table 2-9 branching instructions instruction size function bcc branches to the designated address if condition cc is true. the branching conditions are given below. mnemonic description condition bra (bt) always (true) always brn (bf) never (false) never bhi high c (n (n branches unconditionally to a specified address bsr branches to a subroutine at a specified address jsr branches to a subroutine at a specified address rts returns from a subroutine
38 notation: op: cc: rm: disp: abs: operation field condition field register field displacement absolute address 15 0 87 op cc disp bcc 15 0 87 op rm 0 jmp (@rm) 000 15 0 87 op jmp (@aa:16) abs 15 0 87 op abs jmp (@@aa:8) 15 0 87 op disp bsr 15 0 87 op rm 0 jsr (@rm) 000 15 0 87 op jsr (@aa:16) abs 15 0 87 op abs jsr (@@aa:8) 15 0 87 op rts figure 2-8 branching instruction codes
39 2.5.7 system control instructions table 2-10 describes the system control instructions. figure 2-9 shows their object code formats. table 2-10 system control instructions instruction size * function rte returns from an exception-handling routine sleep causes a transition from active mode to a power-down mode. see section 5, power-down modes, for details. ldc b rs pc + 2 * size: operand size b: byte
40 notation: op: rn: imm: operation field register field immediate data 15 0 87 op rte, sleep, nop 15 0 87 op rn ldc, stc (rn) 15 0 87 op imm andc, orc, xorc, ldc (#xx:8) figure 2-9 system control instruction codes 2.5.8 block data transfer instruction table 2-11 describes the block data transfer instruction. figure 2-10 shows its object code format. table 2-11 block data transfer instruction instruction size function eepmov if r4l 1 certain precautions are required in using the eepmov instruction. see 2.9.3, notes on use of the eepmov instruction, for details.
41 notation: op: operation field 15 0 87 op op figure 2-10 block data transfer instruction code
42 2.6 basic operational timing cpu operation is synchronized by a system clock ( ) or a subclock ( sub ). for details on these clock signals see section 4, clock pulse generators. the period from a rising edge of or sub to the next rising edge is called one state. a bus cycle consists of two states or three states. the cycle differs depending on whether access is to on-chip memory or to on-chip peripheral modules. 2.6.1 access to on-chip memory (ram, rom) access to on-chip memory takes place in two states. the data bus width is 16 bits, allowing access in byte or word size. figure 2-11 shows the on-chip memory access cycle. t 1 state bus cycle t 2 state internal address bus internal read signal internal data bus (read access) internal write signal read data address write data internal data bus (write access) sub or figure 2-11 on-chip memory access cycle
43 2.6.2 access to on-chip peripheral modules on-chip peripheral modules are accessed in two states or three states. the data bus width is 8 bits, so access is by byte size only. this means that for accessing word data, two instructions must be used. figures 2-12 and 2-13 show the on-chip peripheral module access cycle. two-state access to on-chip peripheral modules t 1 state bus cycle t 2 state or internal address bus internal read signal internal data bus (read access) internal write signal read data address write data internal data bus (write access) sub figure 2-12 on-chip peripheral module access cycle (2-state access)
44 three-state access to on-chip peripheral modules t 1 state bus cycle internal address bus internal read signal internal data bus (read access) internal write signal read data address internal data bus (write access) t 2 state t 3 state write data sub or figure 2-13 on-chip peripheral module access cycle (3-state access)
45 2.7 cpu states 2.7.1 overview there are four cpu states: the reset state, program execution state, program halt state, and exception-handling state. the program execution state includes active (high-speed or medium- speed) mode and subactive mode. in the program halt state there are a sleep (high-speed or medium-speed) mode, standby mode, watch mode, and sub-sleep mode. these states are shown in figure 2-14. figure 2-15 shows the state transitions. cpu state reset state program execution state program halt state exception- handling state active (high speed) mode active (medium speed) mode subactive mode sleep (high-speed) mode standby mode watch mode subsleep mode low-power modes the cpu executes successive program instructions at high speed, synchronized by the system clock the cpu executes successive program instructions at reduced speed, synchronized by the system clock the cpu executes successive program instructions at reduced speed, synchronized by the subclock a state in which some or all of the chip functions are stopped to conserve power a transient state in which the cpu changes the processing flow due to a reset or an interrupt the cpu is initialized note: see section 5, power-down modes, for details on the modes and their transitions. sleep (medium-speed) mode figure 2-14 cpu operation states
46 reset state program halt state exception-handling state program execution state reset cleared sleep instruction executed reset occurs interrupt source occurs reset occurs interrupt source occurs exception- handling complete reset occurs figure 2-15 state transitions 2.7.2 program execution state in the program execution state the cpu executes program instructions in sequence. there are three modes in this state, two active modes (high speed and medium speed) and one subactive mode. operation is synchronized with the system clock in active mode (high speed and medium speed), and with the subclock in subactive mode. see section 5, power-down modes for details on these modes. 2.7.3 program halt state in the program halt state there are five modes: two sleep modes (high speed and medium speed), standby mode, watch mode, and subsleep mode. see section 5, power-down modes for details on these modes. 2.7.4 exception-handling state the exception-handling state is a transient state occurring when exception handling is started by a reset or interrupt and the cpu changes its normal processing flow. in exception handling caused by an interrupt, sp (r7) is referenced and the pc and ccr values are saved on the stack. for details on interrupt handling, see section 3.3, interrupts.
47 2.8 memory map the memory map of the h8/3935 and h8/3935r is shown in figure 2-16 (1), that of the h8/3936 and h8/3936r in figure 2-16 (2), and that of the h8/3937 and h8/3937r in figure 2-16 (3). h'0000 h'0029 h'002a h'9fff h'f780 h'ff7f h'ff90 h'ffff interrupt vector area on-chip rom 40 kbytes (40960 bytes) 2048 bytes on-chip ram internal i/o registers (112 bytes) not used not used figure 2-16 (1) h8/3935 and h8/3935r memory map
48 h'0000 h'0029 h'002a h'bfff h'f780 h'ff7f h'ff90 h'ffff interrupt vector area on-chip rom 48 kbytes (49152 bytes) 2048 bytes on-chip ram internal i/o registers (112 bytes) not used not used figure 2-16 (2) h8/3936 and h8/3936r memory map
49 h'0000 h'0029 h'002a h'edff h'f780 h'ff7f h'ff90 h'ffff interrupt vector area on-chip rom 60 kbytes (60928 bytes) 2048 bytes on-chip ram internal i/o registers (112 bytes) not used not used figure 2-16 (3) h8/3937 and h8/3937r memory map
50 2.9 application notes 2.9.1 notes on data access 1. access to empty areas: the address space of the h8/300l cpu includes empty areas in addition to the ram, registers, and rom areas available to the user. if these empty areas are mistakenly accessed by an application program, the following results will occur. data transfer from cpu to empty area: the transferred data will be lost. this action may also cause the cpu to misoperate. data transfer from empty area to cpu: unpredictable data is transferred. 2. access to internal i/o registers: internal data transfer to or from on-chip modules other than the rom and ram areas makes use of an 8-bit data width. if word access is attempted to these areas, the following results will occur. word access from cpu to i/o register area: upper byte: will be written to i/o register. lower byte: transferred data will be lost. word access from i/o register to cpu: upper byte: will be written to upper part of cpu register. lower byte: unpredictable data will be written to lower part of cpu register. byte size instructions should therefore be used when transferring data to or from i/o registers other than the on-chip rom and ram areas. figure 2-17 shows the data size and number of states in which on-chip peripheral modules can be accessed.
51 interrupt vector area (42 bytes) on-chip rom 40 kbytes * on-chip ram not used not used internal i/o registers (112 bytes) access word byte 2 2 2 * h'ff98 to h'ff9f notes: the h8/3935 and h8/3935r are shown as an example. * the address is h'bfff in the h8/3936 and h8/3936r (48-kbyte on-chip rom) and h'edff in the h8/3937 and h8/3937r (60-kbyte on-chip rom). figure 2-17 data size and number of states for access to and from on-chip peripheral modules
52 2.9.2 notes on bit manipulation the bset, bclr, bnot, bst, and bist instructions read one byte of data, modify the data, then write the data byte again. special care is required when using these instructions in cases where two registers are assigned to the same address, in the case of registers that include write- only bits, and when the instruction accesses an i/o port. order of operation operation 1 read read byte data at the designated address 2 modify modify a designated bit in the read data 3 write write the altered byte data to the designated address 1. bit manipulation in two registers assigned to the same address example 1: timer load register and timer counter figure 2-18 shows an example in which two timer registers share the same address. when a bit manipulation instruction accesses the timer load register and timer counter of a reloadable timer, since these two registers share the same address, the following operations take place. order of operation operation 1 read timer counter data is read (one byte) 2 modify the cpu modifies (sets or resets) the bit designated in the instruction 3 write the altered byte data is written to the timer load register the timer counter is counting, so the value read is not necessarily the same as the value in the timer load register. as a result, bits other than the intended bit in the timer load register may be modified to the timer counter value. read write count clock timer counter timer load register reload internal bus figure 2-18 timer configuration example
53 example 2: bset instruction executed designating port 3 p3 7 and p3 6 are designated as input pins, with a low-level signal input at p3 7 and a high-level signal at p3 6 . the remaining pins, p3 5 to p3 0 , are output pins and output low-level signals. in this example, the bset instruction is used to change pin p3 0 to high-level output. [a: prior to executing bset] p3 7 p3 6 p3 5 p3 4 p3 3 p3 2 p3 1 p3 0 input/output input input output output output output output output pin state low level high level low level low level low level low level low level low level pcr3 0 0 1 11111 pdr3 1 0 0 00000 [b: bset instruction executed] bset #0 , @pdr3 the bset instruction is executed designating port 3. [c: after executing bset] p3 7 p3 6 p3 5 p3 4 p3 3 p3 2 p3 1 p3 0 input/output input input output output output output output output pin state low level high level low level low level low level low level low level high level pcr3 0 0 111111 pdr3 0 1 000001 [d: explanation of how bset operates] when the bset instruction is executed, first the cpu reads port 3. since p3 7 and p3 6 are input pins, the cpu reads the pin states (low-level and high-level input). p3 5 to p3 0 are output pins, so the cpu reads the value in pdr3. in this example pdr3 has a value of h'80, but the value read by the cpu is h'40. next, the cpu sets bit 0 of the read data to 1, changing the pdr3 data to h'41. finally, the cpu writes this value (h'41) to pdr3, completing execution of bset. as a result of this operation, bit 0 in pdr3 becomes 1, and p3 0 outputs a high-level signal. however, bits 7 and 6 of pdr3 end up with different values.
54 to avoid this problem, store a copy of the pdr3 data in a work area in memory. perform the bit manipulation on the data in the work area, then write this data to pdr3. [a: prior to executing bset] mov. b mov. b mov. b #80 r0l r0l , , , r0l @ram0 @pdr3 the pdr3 value (h'80) is written to a work area in memory (ram0) as well as to pdr3. p3 7 p3 6 p3 5 p3 4 p3 3 p3 2 p3 1 p3 0 input/output input input output output output output output output pin state low level high level low level low level low level low level low level low level pcr3 0 0 111111 pdr3 1 0 000000 ram0 1 0 000000 [b: bset instruction executed] bset #0 , @ram0 the bset instruction is executed designating the pdr3 work area (ram0). [c: after executing bset] mov. b mov. b @ram0, r0l, r0l @pdr3 the work area (ram0) value is written to pdr3. p3 7 p3 6 p3 5 p3 4 p3 3 p3 2 p3 1 p3 0 input/output input input output output output output output output pin state low level high level low level low level low level low level low level high level pcr3 0 0 111111 pdr3 1 0 000001 ram0 1 0 000001
55 2. bit manipulation in a register containing a write-only bit example 3: bclr instruction executed designating port 3 control register pcr3 as in the examples above, p3 7 and p3 6 are input pins, with a low-level signal input at p3 7 and a high-level signal at p3 6 . the remaining pins, p3 5 to p3 0 , are output pins that output low-level signals. in this example, the bclr instruction is used to change pin p3 0 to an input port. it is assumed that a high-level signal will be input to this input pin. [a: prior to executing bclr] p3 7 p3 6 p3 5 p3 4 p3 3 p3 2 p3 1 p3 0 input/output input input output output output output output output pin state low level high level low level low level low level low level low level low level pcr3 0 0 111111 pdr3 1 0 000000 [b: bclr instruction executed] bset #0 , @pcr3 the bclr instruction is executed designating pcr3. [c: after executing bclr] p3 7 p3 6 p3 5 p3 4 p3 3 p3 2 p3 1 p3 0 input/output output output output output output output output input pin state low level high level low level low level low level low level low level high level pcr3 1 1 111110 pdr3 1 0 000000 [d: explanation of how bclr operates] when the bclr instruction is executed, first the cpu reads pcr3. since pcr3 is a write-only register, the cpu reads a value of h'ff, even though the pcr3 value is actually h'3f. next, the cpu clears bit 0 in the read data to 0, changing the data to h'fe. finally, this value (h'fe) is written to pcr3 and bclr instruction execution ends. as a result of this operation, bit 0 in pcr3 becomes 0, making p3 0 an input port. however, bits 7 and 6 in pcr3 change to 1, so that p3 7 and p3 6 change from input pins to output pins.
56 to avoid this problem, store a copy of the pcr3 data in a work area in memory. perform the bit manipulation on the data in the work area, then write this data to pcr3. [a: prior to executing bclr] mov. b mov. b mov. b #3f r0l r0l , , , r0l @ram0 @pcr3 the pcr3 value (h'3f) is written to a work area in memory (ram0) as well as to pcr3. p3 7 p3 6 p3 5 p3 4 p3 3 p3 2 p3 1 p3 0 input/output input input output output output output output output pin state low level high level low level low level low level low level low level low level pcr3 0 0 111111 pdr3 1 0 000000 ram0 0 0 111111 [b: bclr instruction executed] bset #0 , @ram0 the bclr instruction is executed designating the pcr3 work area (ram0). [c: after executing bclr] mov. b mov. b @ram0, r0l, r0l @pcr3 the work area (ram0) value is written to pcr3. p3 7 p3 6 p3 5 p3 4 p3 3 p3 2 p3 1 p3 0 input/output input input output output output output output output pin state low level high level low level low level low level low level low level high level pcr3 0 0 111110 pdr3 1 0 000000 ram0 0 0 111110
57 table 2-12 lists the pairs of registers that share identical addresses. table 2-13 lists the registers that contain write-only bits. table 2-12 registers with shared addresses register name abbreviation address timer counter and timer load register c tcc/tlc h'ffb5 port data register 1 * 1 pdr1 h'ffd4 port data register 2 * 1 , * 2 pdr2 h'ffd5 port data register 3 * 1 pdr3 h'ffd6 port data register 4 * 1 pdr4 h'ffd7 port data register 5 * 1 pdr5 h'ffd8 port data register 6 * 1 pdr6 h'ffd9 port data register 7 * 1 pdr7 h'ffda port data register 8 * 1 pdr8 h'ffdb port data register 9 * 1 pdr9 h'ffdc port data register a * 1 pdra h'ffdd notes: 1. port data registers have the same addresses as input pins. 2. i/o port for interfacing to flex decoder. table 2-13 registers with write-only bits register name abbreviation address port control register 1 pcr1 h'ffe4 port control register 2 * pcr2 h'ffe5 port control register 3 pcr3 h'ffe6 port control register 4 pcr4 h'ffe7 port control register 5 pcr5 h'ffe8 port control register 6 pcr6 h'ffe9 port control register 7 pcr7 h'ffea port control register 8 pcr8 h'ffeb port control register 9 pcr9 h'ffec port control register a pcra h'ffed timer control register f tcrf h'ffb6 note: * i/o port for interfacing to flex decoder.
58 2.9.3 notes on use of the eepmov instruction ? the eepmov instruction is a block data transfer instruction. it moves the number of bytes specified by r4l from the address specified by r5 to the address specified by r6. ? when setting r4l and r6, make sure that the final destination address (r6 + r4l) does not exceed h'ffff. the value in r6 must not change from h'ffff to h'0000 during execution of the instruction. h'ffff not allowed
59 section 3 exception handling 3.1 overview exception handling is performed in the h8/3937 series and h8/3937r series when a reset or interrupt occurs. table 3-1 shows the priorities of these two types of exception handling. table 3-1 exception handling types and priorities priority exception source time of start of exception handling high reset exception handling starts as soon as the reset state is cleared low interrupt when an interrupt is requested, exception handling starts after execution of the present instruction or the exception handling in progress is completed 3.2 reset 3.2.1 overview a reset is the highest-priority exception. the internal state of the cpu and the registers of the on- chip peripheral modules are initialized. 3.2.2 reset sequence as soon as the res pin goes low, all processing is stopped and the chip enters the reset state. to make sure the chip is reset properly, observe the following precautions. ? at power on: hold the res pin low until the clock pulse generator output stabilizes. ? resetting during operation: hold the res pin low for at least 10 system clock cycles. reset exception handling takes place as follows. ? the cpu internal state and the registers of on-chip peripheral modules are initialized, with the i bit of the condition code register (ccr) set to 1. ? the pc is loaded from the reset exception handling vector address (h'0000 to h'0001), after which the program starts executing from the address indicated in pc.
60 when system power is turned on or off, the res pin should be held low. figure 3-1 shows the reset sequence starting from res input. vector fetch internal address bus internal read signal internal write signal internal data bus (16-bit) res figure 3-1 reset sequence 3.2.3 interrupt immediately after reset after a reset, if an interrupt were to be accepted before the stack pointer (sp: r7) was initialized, pc and ccr would not be pushed onto the stack correctly, resulting in program runaway. to prevent this, immediately after reset exception handling all interrupts are masked. for this reason, the initial program instruction is always executed immediately after a reset. this instruction should initialize the stack pointer (e.g. mov.w #xx: 16, sp).
61 3.3 interrupts 3.3.1 overview the interrupt sources that initiate interrupt exception handling comprise 12 external interrupts (wkp 7 to wkp 0 , irq 4 to irq 1 ), 23 internal interrupts from on-chip peripheral modules, and one internal irq 0 interrupt. table 3-2 shows the interrupt sources, their priorities, and their vector addresses. when more than one interrupt is requested, the interrupt with the highest priority is processed. the interrupts have the following features: ? internal and external interrupts can be masked by the i bit in ccr. when the i bit is set to 1, interrupt request flags can be set but the interrupts are not accepted. ? irq 4 to irq 0 and wkp 7 to wkp 0 can be set to either rising edge sensing or falling edge sensing.
62 table 3-2 interrupt sources and their priorities interrupt source interrupt vector number vector address priority res reset 0 h'0000 to h'0001 high irq 0 irq 0 4 h'0008 to h'0009 irq 1 irq 1 5 h'000a to h'000b irq 2 irq 2 6 h'000c to h'000d irq 3 irq 3 7 h'000e to h'000f irq 4 irq 4 8 h'0010 to h'0011 wkp 0 wkp 0 9 h'0012 to h'0013 wkp 1 wkp 1 wkp 2 wkp 2 wkp 3 wkp 3 wkp 4 wkp 4 wkp 5 wkp 5 wkp 6 wkp 6 wkp 7 wkp 7 sci1 sci1 transfer complete 10 h'0014 to h'0015 timer a timer a overflow 11 h'0016 to h'0017 timer c timer c overflow or underflow 13 h'001a to h'001b timer fl timer fl compare match timer fl overflow 14 h'001c to h'001d timer fh timer fh compare match timer fh overflow 15 h'001e to h'001f timer g timer g input capture timer g overflow 16 h'0020 to h'0021 sci31 sci31 transmit end sci31 transmit data empty sci31 receive data full sci31 overrrun error sci31 framing error sci31 parity error 17 h'0022 to h'0023 sci32 sci32 transmit end sci32 transmit data empty sci32 receive data full sci32 overrun error sci32 framing error sci32 parity error 18 h'0024 to h'0025 a/d a/d conversion end 19 h'0026 to h'0027 (sleep instruction executed) direct transfer 20 h'0028 to h'0029 low note: vector addresses h'0002 to h'0007 and h'0018 to h'0019 are reserved and cannot be used.
63 3.3.2 interrupt control registers table 3-3 lists the registers that control interrupts. table 3-3 interrupt control registers name abbreviation r/w initial value address irq edge select register iegr r/w h'e0 h'fff2 interrupt enable register 1 ienr1 r/w h'00 h'fff3 interrupt enable register 2 ienr2 r/w h'00 h'fff4 interrupt request register 1 irr1 r/w * h'20 h'fff6 interrupt request register 2 irr2 r/w * h'00 h'fff7 wakeup interrupt request register iwpr r/w * h'00 h'fff9 wakeup edge select register wegr r/w h'00 h'ff90 note: * write is enabled only for writing of 0 to clear a flag. 1. irq edge select register (iegr) bit initial value read/write 7 1 6 1 5 1 4 ieg4 0 r/w 3 ieg3 0 r/w 0 ieg0 0 r/w 2 ieg2 0 r/w 1 ieg1 0 r/w iegr is an 8-bit read/write register used to designate whether pins irq 4 to irq 1 , and the internal irq 0 signal used to interface to the flex decoder, are set to rising edge sensing or falling edge sensing. bits 7 to 5: reserved bits bits 7 to 5 are reserved: they are always read as 1 and cannot be modified. bit 4: irq 4 edge select (ieg4) bit 4 selects the input sensing of the irq 4 pin and adtrg pin. bit 4 ieg4 description 0 falling edge of irq 4 and adtrg pin input is detected (initial value) 1 rising edge of irq 4 and adtrg pin input is detected
64 bit 3: irq 3 edge select (ieg3) bit 3 selects the input sensing of the irq 3 pin and tmif pin. bit 3 ieg3 description 0 falling edge of irq 3 and tmif pin input is detected (initial value) 1 rising edge of irq 3 and tmif pin input is detected bit 2: irq 2 edge select (ieg2) bit 2 selects the input sensing of pin irq 2 . bit 2 ieg2 description 0 falling edge of irq 2 pin input is detected (initial value) 1 rising edge of irq 2 pin input is detected bit 1: irq 1 edge select (ieg1) bit 3 selects the input sensing of the irq 1 pin and tmic pin. bit 1 ieg1 description 0 falling edge of irq 1 and tmic pin input is detected (initial value) 1 rising edge of irq 1 and tmic pin input is detected bit 0: irq 0 edge select (ieg0) bit 0 selects the input sensing of the irq 0 signal. bit 0 ieg0 description 0 falling edge of irq 0 signal input is detected (initial value) 1 rising edge of irq 0 signal input is detected note: irq 0 is an internal signal that performs interfacing to the flex decoder incorporated in the chip.
65 2. interrupt enable register 1 (ienr1) bit initial value read/write 7 ienta 0 r/w 6 iens1 0 r/w 5 ienwp 0 r/w 4 ien4 0 r/w 3 ien3 0 r/w 0 ien0 0 r/w 2 ien2 0 r/w 1 ien1 0 r/w ienr1 is an 8-bit read/write register that enables or disables interrupt requests. bit 7: timer a interrupt enable (ienta) bit 7 enables or disables timer a overflow interrupt requests. bit 7 ienta description 0 disables timer a interrupt requests (initial value) 1 enables timer a interrupt requests bit 6: sci1 interrupt enable (iens1) bit 6 enables or disables sci1 transfer complete interrupt requests. bit 6 iens1 description 0 disables sci1 interrupt requests (initial value) 1 enables sci1 interrupt requests note: sci1 is an internal function that performs interfacing to the flex decoder incorporated in the chip. bit 5: wakeup interrupt enable (ienwp) bit 5 enables or disables wkp 7 to wkp 0 interrupt requests. bit 5 ienwp description 0 disables wkp wkp wkp wkp
66 bits 4 to 0: irq 4 to irq 0 interrupt enable (ien4 to ien0) bits 4 to 0 enable or disable irq 4 to irq 0 interrupt requests. bit n ienn description 0 disables interrupt requests from pin irqn irqn irq decoder incorporated in the chip. 3. interrupt enable register 2 (ienr2) bit initial value read/write 7 iendt 0 r/w 6 ienad 0 r/w 5 0 r/w 4 ientg 0 r/w 3 ientfh 0 r/w 0 ienec 0 r/w 2 ientfl 0 r/w 1 ientc 0 r/w ienr2 is an 8-bit read/write register that enables or disables interrupt requests. bit 7: direct transfer interrupt enable (iendt) bit 7 enables or disables direct transfer interrupt requests. bit 7 iendt description 0 disables direct transfer interrupt requests (initial value) 1 enables direct transfer interrupt requests bit 6: a/d converter interrupt enable (ienad) bit 6 enables or disables a/d converter interrupt requests. bit 6 ienad description 0 disables a/d converter interrupt requests (initial value) 1 enables a/d converter interrupt requests bit 5: reserved bit bit 5 is a readable/writable reserved bit. it is initialized to 0 by a reset.
67 bit 4: timer g interrupt enable (ientg) bit 4 enables or disables timer g input capture or overflow interrupt requests. bit 4 ientg description 0 disables timer g interrupt requests (initial value) 1 enables timer g interrupt requests bit 3: timer fh interrupt enable (ientfh) bit 3 enables or disables timer fh compare match and overflow interrupt requests. bit 3 ientfh description 0 disables timer fh interrupt requests (initial value) 1 enables timer fh interrupt requests bit 2: timer fl interrupt enable (ientfl) bit 2 enables or disables timer fl compare match and overflow interrupt requests. bit 2 ientfl description 0 disables timer fl interrupt requests (initial value) 1 enables timer fl interrupt requests bit 1: timer c interrupt enable (ientc) bit 1 enables or disables timer c overflow and underflow interrupt requests. bit 1 ientc description 0 disables timer c interrupt requests (initial value) 1 enables timer c interrupt requests bit 0: reserved bit bit 0 is reserved: it is always read as 0 and cannot be modified. for details of sci31 interrupt control, see 6. serial control register 3 (scr3) in section 10.3.2.
68 4. interrupt request register 1 (irr1) bit initial value read/write 7 irrta 0 r/(w) * 6 irrs1 0 r/(w) * 5 1 4 irri4 0 r/(w) * 3 irri3 0 r/(w) * 0 irri0 0 r/(w) * 2 irri2 0 r/(w) * 1 irri1 0 r/(w) * note: * only a write of 0 for flag clearing is possible irr1 is an 8-bit read/write register, in which a corresponding flag is set to 1 when a timer a, sci1, or irq 4 to irq 0 interrupt is requested. the flags are not cleared automatically when an interrupt is accepted. it is necessary to write 0 to clear each flag. bit 7: timer a interrupt request flag (irrta) bit 7 irrta description 0 clearing conditions: when irrta = 1, it is cleared by writing 0 (initial value) 1 setting conditions: when the timer a counter value overflows from h'ff to h'00 bit 6: sci1 interrupt request flag (irrs1) bit 6 irrs1 description 0 clearing conditions: when irrs1 = 1, it is cleared by writing 0 (initial value) 1 setting conditions: when sci1 completes transfer note: sci1 is an internal function that performs interfacing to the flex decoder incorporated in the chip. bit 5: reserved bit bit 5 is reserved; it is always read as 1 and cannot be modified.
69 bits 4 to 0: irq 4 to irq 0 interrupt request flags (irri4 to irri0) bit n irrin description 0 clearing conditions: when irrin = 1, it is cleared by writing 0 (initial value) 1 setting conditions: when pin irqn irq decoder incorporated in the chip. 5. interrupt request register 2 (irr2) bit initial value read/write 7 irrdt 0 r/(w) * 6 irrad 0 r/(w) * 5 0 r/w 4 irrtg 0 r/(w) * 3 irrtfh 0 r/(w) * 0 irrec 0 r/(w) * 2 irrtfl 0 r/(w) * 1 irrtc 0 r/(w) * note: * only a write of 0 for flag clearing is possible irr2 is an 8-bit read/write register, in which a corresponding flag is set to 1 when a direct transfer, a/d converter, timer g, timer fh, timer fc, or timer c interrupt is requested. the flags are not cleared automatically when an interrupt is accepted. it is necessary to write 0 to clear each flag. bit 7: direct transfer interrupt request flag (irrdt) bit 7 irrdt description 0 clearing conditions: when irrdt = 1, it is cleared by writing 0 (initial value) 1 setting conditions: when a direct transfer is made by executing a sleep instruction while dton = 1 in syscr2
70 bit 6: a/d converter interrupt request flag (irrad) bit 6 irrad description 0 clearing conditions: when irrad = 1, it is cleared by writing 0 (initial value) 1 setting conditions: when a/d conversion is completed and adsf is cleared to 0 in adsr bit 5: reserved bit bit 5 is a readable/writable reserved bit. it is initialized to 0 by a reset. bit 4: timer g interrupt request flag (irrtg) bit 4 irrtg description 0 clearing conditions: when irrtg = 1, it is cleared by writing 0 (initial value) 1 setting conditions: when the tmig pin is designated for tmig input and the designated signal edge is input, and when tcg overflows while ovie is set to 1 in tmg bit 3: timer fh interrupt request flag (irrtfh) bit 3 irrtfh description 0 clearing conditions: when irrtfh = 1, it is cleared by writing 0 (initial value) 1 setting conditions: when tcfh and ocrfh match in 8-bit timer mode, or when tcf (tcfl, tcfh) and ocrf (ocrfl, ocrfh) match in 16-bit timer mode bit 2: timer fl interrupt request flag (irrtfl) bit 2 irrtfl description 0 clearing conditions: when irrtfl= 1, it is cleared by writing 0 (initial value) 1 setting conditions: when tcfl and ocrfl match in 8-bit timer mode
71 bit 1: timer c interrupt request flag (irrtc) bit 1 irrtc description 0 clearing conditions: when irrtc= 1, it is cleared by writing 0 (initial value) 1 setting conditions: when the timer c counter value overflows (from h'ff to h'00) or underflows (from h'00 to h'ff) bit 0: reserved bit bit 0 is reserved: it is always read as 0 and cannot be modified. 6. wakeup interrupt request register (iwpr) bit initial value read/write 7 iwpf7 0 r/(w) * 6 iwpf6 0 r/(w) * 5 iwpf5 0 r/(w) * 4 iwpf4 0 r/(w) * 3 iwpf3 0 r/(w) * 0 iwpf0 0 r/(w) * 2 iwpf2 0 r/(w) * 1 iwpf1 0 r/(w) * note: * all bits can only be written with 0, for flag clearing. iwpr is an 8-bit read/write register containing wakeup interrupt request flags. when one of pins wkp wkp bits 7 to 0: wakeup interrupt request flags (iwpf7 to iwpf0) bit n iwpfn description 0 clearing conditions: when iwpfn= 1, it is cleared by writing 0 (initial value) 1 setting conditions: when pin wkp
72 7. wakeup edge select register (wegr) bit initial value read/write 7 wkegs7 0 r/w 6 wkegs6 0 r/w 5 wkegs5 0 r/w 4 wkegs4 0 r/w 3 wkegs3 0 r/w 0 wkegs0 0 r/w 2 wkegs2 0 r/w 1 wkegs1 0 r/w wegr is an 8-bit read/write register that specifies rising or falling edge sensing for pins wkpn. wegr is initialized to h'00 by a reset. bit n: wkp wkp bit n wkegs description 0 wkp wkp 3.3.3 external interrupts there are 12 external interrupts: irq 4 to irq 0 and wkp 7 to wkp 0 . 1. interrupts wkp 7 to wkp 0 interrupts wkp 7 to wkp 0 are requested by either rising or falling edge input to pins wkp wkp wkp wkp irq irq
73 when these pins are designated as pins irq irq 3.3.4 internal interrupts 1. internal interrupts there are 23 internal interrupts that can be requested by the on-chip peripheral modules. when a peripheral module requests an interrupt, the corresponding bit in irr1 or irr2 is set to 1. recognition of individual interrupt requests can be disabled by clearing the corresponding bit in ienr1 or ienr2. all these interrupts can be masked by setting the i bit to 1 in ccr. when internal interrupt handling is initiated, the i bit is set to 1 in ccr. vector numbers from 20 to 13, 11, and 10 are assigned to these interrupts. table 3-2 shows the order of priority of interrupts from on-chip peripheral modules. 2. irq 0 interrupt the irq 0 interrupt is requested by the ready decoder incorporated in the chip. rising or falling edge sensing can be selected for the irq 0 interrupt by means of bit ieg0 in iegr. when the designated edge is input while the irq 0 function is selected by bit irq 0 in pmr3, bit irri0 is set to 1 in irr1, and an interrupt is requested. interrupt request recognition can be disabled by clearing bit ien0 to 0 in ienr1. in addition, all interrupts can be masked by setting the i bit to 1 in ccr. when irq 0 interrupt exception handling is initiated, the i bit is set to 1 in ccr. the vector number for irq 0 interrupt exception handling is 4. see table 3-2 for details.
74 3.3.5 interrupt operations interrupts are controlled by an interrupt controller. figure 3-2 shows a block diagram of the interrupt controller. figure 3-3 shows the flow up to interrupt acceptance. interrupt controller priority decision logic interrupt request ccr (cpu) i external or internal interrupts external interrupts or internal interrupt enable signals figure 3-2 block diagram of interrupt controller interrupt operation is described as follows. ? ? ? ?
75 ? ? ?
76 pc contents saved ccr contents saved i figure 3-3 flow up to interrupt acceptance
77 pc and ccr saved to stack sp (r7) sp 1 sp 2 sp 3 sp 4 stack area sp + 4 sp + 3 sp + 2 sp + 1 sp (r7) even address prior to start of interrupt exception handling after completion of interrupt exception handling notation: pc h : pc l : ccr: sp: upper 8 bits of program counter (pc) lower 8 bits of program counter (pc) condition code register stack pointer notes: ccr ccr pc h pc l 1. 2. * pc shows the address of the first instruction to be executed upon return from the interrupt handling routine. register contents must always be saved and restored by word access, starting from an even-numbered address. ignored on return. * figure 3-4 stack state after completion of interrupt exception handling figure 3-5 shows a typical interrupt sequence.
78 vector fetch internal address bus internal read signal internal write signal (2) internal data bus (16 bits) interrupt request signal (9) (1) internal processing prefetch instruction of interrupt-handling routine (1) instruction prefetch address (instruction is not executed. address is saved as pc contents, becoming return address.) (2)(4) instruction code (not executed) (3) instruction prefetch address (instruction is not executed.) (5) sp 2 (6) sp 4 (7) ccr (8) vector address (9) starting address of interrupt-handling routine (contents of vector) (10) first instruction of interrupt-handling routine (3) (9) (8) (6) (5) (4) (1) (7) (10) stack access internal processing instruction prefetch interrupt level decision and wait for end of instruction interrupt is accepted figure 3-5 interrupt sequence
79 3.3.6 interrupt response time table 3-4 shows the number of wait states after an interrupt request flag is set until the first instruction of the interrupt handler is executed. table 3-4 interrupt wait states item states total waiting time for completion of executing instruction * 1 to 13 15 to 27 saving of pc and ccr to stack 4 vector fetch 2 instruction fetch 4 internal processing 4 note: * not including eepmov instruction.
80 3.4 application notes 3.4.1 notes on stack area use when word data is accessed in the h8/3937 series and h8/3937r series, the least significant bit of the address is regarded as 0. access to the stack always takes place in word size, so the stack pointer (sp: r7) should never indicate an odd address. use push rn (mov.w rn, @ sp) or pop rn (mov.w @sp+, rn) to save or restore register values. setting an odd address in sp may cause a program to crash. an example is shown in figure 3-6. pc pc r1l pc sp sp sp h'fefc h'fefd h'feff r7 sp set to h'feff stack accessed beyond sp bsr instruction contents of pc are lost h notation: pc h : pc l : r1l: sp: upper byte of program counter lower byte of program counter general register r1l stack pointer figure 3-6 operation when odd address is set in sp when ccr contents are saved to the stack during interrupt exception handling or restored when rte is executed, this also takes place in word size. both the upper and lower bytes of word data are saved to the stack; on return, the even address contents are restored to ccr while the odd address contents are ignored.
81 3.4.2 notes on rewriting port mode registers when a port mode register is rewritten to switch the functions of external interrupt pins, the following points should be observed. when an external interrupt pin function is switched by rewriting the port mode register that controls pins irq irq wkp wkp
82 table 3-5 conditions under which interrupt request flag is set to 1 interrupt request flags set to 1 conditions irr1 irri4 when pmr1 bit irq4 is changed from 0 to 1 while pin irq irq irq irq irq irq irq irq irq irq wkp wkp wkp wkp wkp wkp wkp wkp
83 ccr i bit 1 set port mode register bit execute nop instruction interrupts masked. (another possibility is to disable the relevant interrupt in interrupt enable register 1.) after setting the port mode register bit, first execute at least one instruction (e.g., nop), then clear the interrupt request flag to 0 interrupt mask cleared clear interrupt request flag to 0 ccr i bit 0 figure 3-7 port mode register setting and interrupt request flag clearing procedure 3.4.3 notes on interrupt request flag clearing methods either of the following methods should be used for flag clearing in the interrupt request registers (irr1, irr2, iwpr). method 1 clear the interrupt request flag with a bclr instruction. (recommended method) sample coding for clearing irri1 (bit 1 of irr1): bclr #1,@irr1:8 method 2 write data to the interrupt request register with 0 for the relevant interrupt request flag and 1s for the other flags. (faster execution than method 1) sample coding for clearing irri1 (bit 1 of irr1): mov.b #b'11111101,r1l mov.b r1l,@irr1:8
84
85 section 4 clock pulse generators 4.1 overview clock oscillator circuitry (cpg: clock pulse generator) is provided on-chip, including both a system clock pulse generator and a subclock pulse generator. the system clock pulse generator consists of a system clock oscillator and system clock dividers. the subclock pulse generator consists of a subclock oscillator circuit and a subclock divider. 4.1.1 block diagram figure 4-1 shows a block diagram of the clock pulse generators. system clock oscillator system clock divider (1/2) subclock oscillator subclock oscillator (1/2) subclock divider (1/2, 1/4, 1/8) system clock divider system clock pulse generator subclock pulse generator prescaler s (13 bits) prescaler w (5 bits) osc osc 1 2 dx dx 1 2 osc (f ) osc w w dec (f ) w ? /2 osc ? /2 w ? /8 w sub ?2 to ?8192 ? /2 w ? /4 w ? /8 to ? /128 w w osc /128 osc /64 osc /32 osc /16 ? /4 w figure 4-1 block diagram of clock pulse generators 4.1.2 system clock and subclock the basic clock signals that drive the cpu and on-chip peripheral modules are ?and sub . five of the clock signals have names: ?is the system clock, sub is the subclock, osc is the oscillator clock, w is the watch clock, and dec is the decoder clock. the clock signals available for use by peripheral modules are ?2, ?4, ?8, ?16, ?32, ?64, ?128, ?256, ?512, ?1024, ?2048, ?4096, ?8192, w , w /2, w /4, w /8, w /16, w /32, w /64, w /128, and dec . the clock requirements differ from one module to another.
86 4.2 system clock generator clock pulses can be supplied to the system clock divider either by connecting a crystal or ceramic oscillator, or by providing external clock input. 1. connecting a crystal oscillator figure 4-2 shows a typical method of connecting a crystal oscillator. 1 2 c 1 c 2 osc osc r = 1 m ? 20% f r f oscillation recommended value frequency manufacturer for c 1 and c 2 4.0 mhz nihon denpa kogyo 12 pf 20% figure 4-2 typical connection to crystal oscillator figure 4-3 shows the equivalent circuit of a crystal oscillator. an oscillator having the characteristics given in table 4-1 should be used. c s c 0 r s osc 1 osc 2 l s figure 4-3 equivalent circuit of crystal oscillator table 4-1 crystal oscillator parameters frequency 4.193 mhz r s (max) 100 ? c 0 (max) 16 pf
87 2. connecting a ceramic oscillator figure 4-4 shows a typical method of connecting a ceramic oscillator. 1 2 c 1 c 2 osc osc r = 1 m ? 20% f r f oscillation recommended value frequency manufacturer for c 1 and c 2 4.0 mhz murata seisakusho 30 pf 10% figure 4-4 typical connection to ceramic oscillator 3. notes on board design when generating clock pulses by connecting a crystal or ceramic oscillator, pay careful attention to the following points. avoid running signal lines close to the oscillator circuit, since the oscillator may be adversely affected by induction currents. (see figure 4-5.) the board should be designed so that the oscillator and load capacitors are located as close as possible to pins osc 1 and osc 2 . osc osc c 1 c 2 signal a signal b 2 1 to be avoided figure 4-5 board design of oscillator circuit
88 4. external clock input method connect an external clock signal to pin osc 1 , and leave pin osc 2 open. figure 4-6 shows a typical connection. 1 2 osc osc external clock input open figure 4-6 external clock input (example) frequency oscillator clock ( osc ) duty cycle 45% to 55% caution when a crystal or ceramic oscillator element is connected, circuit constants will differ according to the oscillator element, installation circuit stray capacitance, and so forth, and so should be determined in consultation with the crystal or ceramic oscillator element manufacturer.
89 4.3 subclock generator 1. connecting a 76.8-khz/160-khz crystal oscillator clock pulses can be supplied to the subclock divider by connecting a 76.8-khz/160-khz crystal oscillator, as shown in figure 4-7. follow the same precautions as noted under 3. notes on board design for the system clock in 4.2. c dx dx 1 c 2 1 2 c = c = 12.5 pf (typ.) 12 figure 4-7 typical connection to 76.8-khz/160-khz crystal oscillator (subclock) figure 4-8 shows the equivalent circuit of the 76.8-khz/160-khz crystal oscillator. c s c 0 lr s f w = 76.8 khz/160 khz s dx 1 dx 2 figure 4-8 equivalent circuit of 76.8-khz/160-khz crystal oscillator 2. pin connection when not using subclock when the subclock is not used, connect pin dx 1 to gnd and leave pin dx 2 open, as shown in figure 4-9. open gnd dx 1 dx 2 figure 4-9 pin connection when not using subclock
90 3. external clock input connect the external clock to the dx 1 pin and leave the dx 2 pin open, as shown in figure 4-10. external clock input open dx 1 dx 2 figure 4-10 pin connection when inputting external clock frequency subclock (?) duty 45% to 55%
91 4.4 prescalers the h8/3937 series and 3937r series are equipped with two on-chip prescalers having different input clocks (prescaler s and prescaler w). prescaler s is a 13-bit counter using the system clock (? as its input clock. its prescaled outputs provide internal clock signals for on-chip peripheral modules. prescaler w is a 5-bit counter using a 38.4 khz or 80 khz signal, obtained by dividing a 76.8 khz or 160 khz signal by 2, further divided by 4 ( w /4) as its input clock. its prescaled outputs are used for timer a time-base operations. 1. prescaler s (pss) prescaler s is a 13-bit counter using the system clock (? as its input clock. it is incremented once per clock period. prescaler s is initialized to h'0000 by a reset, and starts counting on exit from the reset state. in standby mode, watch mode, subactive mode, and subsleep mode, the system clock pulse generator stops. prescaler s also stops and is initialized to h'0000. the cpu cannot read or write prescaler s. the output from prescaler s is shared by timer a, timer c, timer f, timer g, sci1, sci31, sc32, the a/d converter, and the watchdog timer. the divider ratio can be set separately for each on- chip peripheral function. in active (medium-speed) mode the clock input to prescaler s is ?sc/16, ?sc/32, ?sc/64, or ?sc/128. 2. prescaler w (psw) prescaler w is a 5-bit counter using a 38.4 khz or 80 khz signal, obtained by dividing a 76.8 khz or 160 khz signal by 2, further divided by 4 ( w /4) as its input clock. prescaler w is initialized to h'00 by a reset, and starts counting on exit from the reset state. even in standby mode, watch mode, subactive mode, or subsleep mode, prescaler w continues functioning so long as clock signals are supplied to pins dx1 and dx2. prescaler w can be reset by setting 1 in bits tma3 and tma2 of timer mode register a (tma). output from prescaler w can be used to drive timer a, in which case timer a functions as a time base.
92 4.5 note on oscillators oscillator characteristics are closely related to board design and should be carefully evaluated by the user in mask rom and ztat versions, referring to the examples shown in this section. oscillator circuit constants will differ depending on the oscillator element, stray capacitance in its interconnecting circuit, and other factors. suitable constants should be determined in consultation with the oscillator element manufacturer. design the circuit so that the oscillator element never receives voltages exceeding its maximum rating. 4.5.1 definition of oscillation settling standby time figure 4-11 shows the oscillation waveform (osc2), system clock (?, and microcomputer operating mode when a transition is made from standby mode, watch mode, or subactive mode, to active (high-speed/medium-speed) mode, with an oscillator element connected to the system clock oscillator. as shown in figure 4-11, as the system clock oscillator is halted in standby mode, watch mode, and subactive mode, when a transition is made to active (high-speed/medium-speed) mode, the sum of the following two times (oscillation settling time and standby time) is required. 1. oscillation settling time (t rc ) the time from the point at which the system clock oscillator oscillation waveform starts to change when an interrupt is generated, until the amplitude of the oscillation waveform increases and the oscillation frequency stabilizes. 2. standby time the time required for the cpu and peripheral functions to begin operating after the oscillation waveform frequency and system clock have stabilized. the standby time setting is selected with standby timer select bits 2 to 0 (sts2 to sts0) (bits 6 to 4 in system control register 1 (syscr1)).
93 oscillation waveform (osc2) system clock ( ) oscillation settling time operating mode standby mode, watch mode, or subactive mode standby time oscillation settling standby time active (high-speed) mode or active (medium-speed) mode interrupt accepted figure 4-11 oscillation settling standby time when standby mode, watch mode, or subactive mode is cleared by an interrupt or reset, and a transition is made to active (high-speed/medium-speed) mode, the oscillation waveform begins to change at the point at which the interrupt is accepted. therefore, when an oscillator element is connected in standby mode, watch mode, or subactive mode, since the system clock oscillator is halted, the time from the point at which this oscillation waveform starts to change until the amplitude of the oscillation waveform increases and the oscillation frequency stabilizes?hat is, the oscillation settling time?s required. the oscillation settling time in the case of these state transitions is the same as the oscillation settling time at power-on (the time from the point at which the power supply voltage reaches the prescribed level until the oscillation stabilizes), specified by "oscillation settling time t rc " in the ac characteristics. meanwhile, once the system clock has halted, a standby time of at least 8 states is necessary in order for the cpu and peripheral functions to operate normally. thus, the time required from interrupt generation until operation of the cpu and peripheral functions is the sum of the above described oscillation settling time and standby time. this total time is called the oscillation settling standby time, and is expressed by equation (1) below. oscillation settling standby time = oscillation settling time + standby time = t rc + (8 to 16,384 states) ................. (1)
94 therefore, when a transition is made from standby mode, watch mode, or subactive mode, to active (high-speed/medium-speed) mode, with an oscillator element connected to the system clock oscillator, careful evaluation must be carried out on the installation circuit before deciding on the oscillation settling standby time. in particular, since the oscillation settling time is affected by installation circuit constants, stray capacitance, and so forth, suitable constants should be determined in consultation with the oscillator element manufacturer. 4.5.2 notes on use of crystal oscillator element (excluding ceramic oscillator element) when a microcomputer operates, the internal power supply potential fluctuates slightly in synchronization with the system clock. depending on the individual crystal oscillator element characteristics, the oscillation waveform amplitude may not be sufficiently large immediately after the oscillation settling standby time, making the oscillation waveform susceptible to influence by fluctuations in the power supply potential. in this state, the oscillation waveform may be disrupted, leading to an unstable system clock and erroneous operation of the microcomputer. if erroneous operation occurs, change the setting of standby timer select bits 2 to 0 (sts2 to sts0) (bits 6 to 4 in system control register 1 (syscr1)) to give a longer standby time. for example, if erroneous operation occurs with a standby time setting of 16 states, check the operation with a standby time setting of 1,024 states or more. if the same kind of erroneous operation occurs after a reset as after a state transition, hold the res pin low for a longer period.
95 section 5 power-down modes 5.1 overview the h8/3937 series and h8/3937r series have nine modes of operation after a reset. these include eight power-down modes, in which power dissipation is significantly reduced. table 5-1 gives a summary of the eight operating modes. table 5-1 operating modes operating mode description active (high-speed) mode the cpu and all on-chip peripheral functions are operable on the system clock in high-speed operation. the flex decoder is independently operable on the subclock. active (medium-speed) mode the cpu and all on-chip peripheral functions are operable on the system clock in low-speed operation. the flex decoder is independently operable on the subclock. subactive mode the cpu is operable on the subclock in low-speed operation. the flex decoder is independently operable on the subclock. sleep (high-speed) mode the cpu halts. on-chip peripheral functions are operable on the system clock. the flex decoder is independently operable on the subclock. sleep (medium-speed) mode the cpu halts. on-chip peripheral functions operate at a frequency of 1/64, 1/32, 1/16, or 1/8 of the system clock frequency. the flex decoder is independently operable on the subclock. subsleep mode the cpu halts. timer a, timer c, timer g, timer f, the wdt, sci1, sci31, sci32, and the flex decoder are operable on the subclock. watch mode the timer a time-base function, timer f, timer g, and the flex decoder are operable on the subclock. standby mode the cpu and all on-chip peripheral functions halt. the flex decoder is independently operable on the subclock. module standby mode individual on-chip peripheral functions specified by software enter standby mode and halt. of these nine operating modes, all but the active (high-speed) mode are power-down modes. in this section the two active modes (high-speed and medium speed) will be referred to collectively as active mode. figure 5-1 shows the transitions among these operation modes. table 5-2 indicates the internal states in each mode.
96 program halt state sleep instruction * e sleep instruction * c sleep instruction * h sleep instruction * i sleep instruction * g sleep instruction * f program execution state sleep instruction * a program halt state sleep instruction * i power-down modes a transition between different modes cannot be made to occur simply because an interrupt request is generated. make sure that interrupt handling is performed after the interrupt is accepted. details on the mode transition conditions are given in the explanations of each mode, in sections 5-2 through 5-8. notes: 1. 2. mode transition conditions (1) a b c d e f g h i j lson mson ssby dton 0 0 1 0 * 0 0 0 1 0 0 1 * * * 0 1 1 * 0 0 0 0 1 1 0 0 1 1 1 0 0 0 0 0 1 1 1 1 1 * don t care mode transition conditions (2) 1 interrupt sources timer a, timer f, timer g interrupt, irq 0 interrupt, wkp 7 to wkp 0 interrupt timer a, timer c, timer f, timer g, sci1, sci31, sci32 interrupt, irq 4 to irq 0 interrupts, wkp 7 to wkp 0 interrupts all interrupts irq 1 or irq 0 interrupt, wkp 7 to wkp 0 interrupts 2 3 4 * 3 * 3 * 2 * 1 * 4 * 4 * 1 standby mode watch mode subactive mode active (medium-speed) mode active (high-speed) mode sleep (high-speed) mode sleep (medium-speed) mode subsleep mode sleep instruction * a sleep instruction * e sleep instruction * d sleep instruction * b sleep instruction * j * 1 sleep instruction * e sleep instruction * b tma3 * * 1 0 1 * * 1 1 1 sleep instruction * d reset state figure 5-1 mode transition diagram
97 table 5-2 internal state in each operating mode active mode sleep mode function high- speed medium- speed high- speed medium- speed watch mode subactive mode subsleep mode standby mode system clock oscillator functions functions functions functions halted halted halted halted subclock oscillator functions functions functions functions functions functions functions functions cpu instructions functions functions halted halted halted functions halted halted operations ram retained retained retained retained retained registers i/o ports retained * 1 irq 0 interrupt irq 0 functions functions functions functions functions functions functions functions external irq 1 functions functions functions functions retained * 5 functions functions functions interrupts irq 2 retained * 5 irq 3 irq 4 wkp 0 functions functions functions functions functions functions functions functions wkp 1 wkp 2 wkp 3 wkp 4 wkp 5 wkp 6 wkp 7 peripheral timer a functions functions functions functions functions * 4 functions * 4 functions * 4 retained functions timer c retained functions/ retained * 2 functions/ retained * 2 retained wdt functions/ retained * 7 retained timer g, timer f functions/ retained * 6 functions/ retained * 2 functions/ retained * 2 sci1 retained functions/ retained * 2 functions/ retained * 2 retained sci31, sci32 reset functions/ retained * 3 functions/ retained * 3 reset a/d converter retained retained retained retained flex decoder functions functions functions functions notes: 1. register contents are retained, but output is high-impedance state. 2. functions if an external clock or the w /4 internal clock is selected; otherwise halted and retained. 3. functions if w /2 is selected as the internal clock; otherwise halted and retained. 4. functions if the time-base function is selected. 5. external interrupt requests are ignored. interrupt request register contents are not altered. 6. functions if w /4 is selected as the external or internal clock; otherwise halted and retained. 7. functions if w /32 is selected as the internal clock; otherwise halted and retained.
98 5.1.1 system control registers the operation mode is selected using the system control registers described in table 5-3. table 5-3 system control registers name abbreviation r/w initial value address system control register 1 syscr1 r/w h'07 h'fff0 system control register 2 syscr2 r/w h'f0 h'fff1 1. system control register 1 (syscr1) bit initial value read/write 7 ssby 0 r/w 6 sts2 0 r/w 5 sts1 0 r/w 4 sts0 0 r/w 3 lson 0 r/w 0 ma0 1 r/w 2 1 1 ma1 1 r/w syscr1 is an 8-bit read/write register for control of the power-down modes. upon reset, syscr1 is initialized to h'07. bit 7: software standby (ssby) this bit designates transition to standby mode or watch mode. bit 7 ssby description 0 ? when a sleep instruction is executed in active mode, a transition is made to sleep mode (initial value) ? when a sleep instruction is executed in subactive mode, a transition is made to subsleep mode 1 ? when a sleep instruction is executed in active mode, a transition is made to standby mode or watch mode ? when a sleep instruction is executed in subactive mode, a transition is made to watch mode
99 bits 6 to 4: standby timer select 2 to 0 (sts2 to sts0) these bits designate the time the cpu and peripheral modules wait for stable clock operation after exiting from standby mode or watch mode to active mode due to an interrupt. the designation should be made according to the operating frequency so that the waiting time is at least equal to the oscillation settling time. bit 6 sts2 bit 5 sts1 bit 4 sts0 description 0 0 0 wait time = 8,192 states (initial value) 0 0 1 wait time = 16,384 states 0 1 0 wait time = 1,024 states 0 1 1 wait time = 2,048 states 1 0 0 wait time = 4,096 states 1 0 1 wait time = 2 states (external clock input mode) 1 1 0 wait time = 8 states 1 1 1 wait time = 16 states note: when inputting the external clock, set the standby timer select to the external clock input mode. also, when not using the external clock, do not set the standby timer select to the external clock input mode. bit 3: low speed on flag (lson) this bit chooses the system clock (? or subclock ( sub ) as the cpu operating clock when watch mode is cleared. the resulting operation mode depends on the combination of other control bits and interrupt input. bit 3 lson description 0 the cpu operates on the system clock ( ) (initial value) 1 the cpu operates on the subclock ( sub ) bit 2: reserved bit bit 2 is reserved: it is always read as 1 and cannot be modified.
100 bits 1 and 0: active (medium-speed) mode clock select (ma1, ma0) bits 1 and 0 choose osc /128, osc /64, osc /32, or osc /16 as the operating clock in active (medium-speed) mode and sleep (medium-speed) mode. ma1 and ma0 should be written in active (high-speed) mode or subactive mode. bit 1 ma1 bit 0 ma0 description 00 osc /16 01 osc /32 10 osc /64 11 osc /128 (initial value) 2. system control register 2 (syscr2) bit initial value read/write 7 1 6 1 5 1 4 nesel 1 r/w 3 dton 0 r/w 0 sa0 0 r/w 2 mson 0 r/w 1 sa1 0 r/w syscr2 is an 8-bit read/write register for power-down mode control. bits 7 to 5: reserved bits these bits are reserved; they are always read as 1, and cannot be modified. bit 4: noise elimination sampling frequency select (nesel) this bit selects the frequency at which the watch clock signal ( w ) generated by the subclock pulse generator is sampled, in relation to the oscillator clock ( osc ) generated by the system clock pulse generator. when osc = 6 to 10 mhz, clear nesel to 0. bit 4 nesel description 0 sampling rate is osc /16 1 sampling rate is osc /4 (initial value)
101 bit 3: direct transfer on flag (dton) this bit designates whether or not to make direct transitions among active (high-speed), active (medium-speed) and subactive mode when a sleep instruction is executed. the mode to which the transition is made after the sleep instruction is executed depends on a combination of this and other control bits. bit 3 dton description 0 ? when a sleep instruction is executed in active mode, a transition is made to standby mode, watch mode, or sleep mode (initial value) ? when a sleep instruction is executed in subactive mode, a transition is made to watch mode or subsleep mode 1 ? when a sleep instruction is executed in active (high-speed) mode, a direct transition is made to active (medium-speed) mode if ssby = 0, mson = 1, and lson = 0, or to subactive mode if ssby = 1, tma3 = 1, and lson = 1 ? when a sleep instruction is executed in active (medium-speed) mode, a direct transition is made to active (high-speed) mode if ssby = 0, mson = 0, and lson = 0, or to subactive mode if ssby = 1, tma3 = 1, and lson = 1 ? when a sleep instruction is executed in subactive mode, a direct transition is made to active (high-speed) mode if ssby = 1, tma3 = 1, lson = 0, and mson = 0, or to active (medium-speed) mode if ssby = 1, tma3 = 1, lson = 0, and mson = 1 bit 2: medium speed on flag (mson) after standby, watch, or sleep mode is cleared, this bit selects active (high-speed) or active (medium-speed) mode. bit 2 mson description 0 operation in active (high-speed) mode (initial value) 1 operation in active (medium-speed) mode
102 bits 1 and 0: subactive mode clock select (sa1, sa0) these bits select the cpu clock rate ( w /2, w /4, or w /8) in subactive mode. sa1 and sa0 cannot be modified in subactive mode. bit 1 sa1 bit 0 sa0 description 00 w /8 (initial value) 01 w /4 1 * w /2 * : don t care
103 5.2 sleep mode 5.2.1 transition to sleep mode 1. transition to sleep (high-speed) mode the system goes from active mode to sleep (high-speed) mode when a sleep instruction is executed while the ssby and lson bits in syscr1 are cleared to 0 and the mson and dton bits in syscr2 are also cleared to 0. in sleep mode cpu operation is halted but the on-chip peripheral functions. cpu register contents are retained. 2. transition to sleep (medium-speed) mode the system goes from active mode to sleep (medium-speed) mode when a sleep instruction is executed while the ssby and lson bits in syscr1 are cleared to 0, the mson bit in syscr2 is set to 1, and the dton bit in syscr2 is cleared to 0. in sleep (medium-speed) mode, as in sleep (high-speed) mode, cpu operation is halted but the on-chip peripheral functions are operational. the clock frequency in sleep (medium-speed) mode is determined by the ma1 and ma0 bits in syscr1. cpu register contents are retained. the cpu may operate at a 1/2 state faster timing at transition to sleep (medium-speed) mode. 5.2.2 clearing sleep mode sleep mode is cleared by any interrupt (timer a, timer c, timer f, timer g, asynchronous counter, irq 4 to irq 0 , wkp 7 to wkp 0 , sci1, sci31, sci32, or a/d converter), or by input at the res pin. ? clearing by interrupt when an interrupt is requested, sleep mode is cleared and interrupt exception handling starts. a transition is made from sleep (high-speed) mode to active (high-speed) mode, or from sleep (medium-speed) mode to active (medium-speed) mode. sleep mode is not cleared if the i bit of the condition code register (ccr) is set to 1 or the particular interrupt is disabled in the interrupt enable register. to synchronize the interrupt request signal with the system clock, up to 2/?(s) delay may occur after the interrupt request signal occurrence, before the interrupt exception handling start. ? clearing by res input when the res pin goes low, the cpu goes into the reset state and sleep mode is cleared.
104 5.2.3 clock frequency in sleep (medium-speed) mode operation in sleep (medium-speed) mode is clocked at the frequency designated by the ma1 and ma0 bits in syscr1.
105 5.3 standby mode 5.3.1 transition to standby mode the system goes from active mode to standby mode when a sleep instruction is executed while the ssby bit in syscr1 is set to 1, the lson bit in syscr1 is cleared to 0, and bit tma3 in tma is cleared to 0. in standby mode the clock supply from the clock pulse generator is halted, so the cpu and peripheral modules other than the flex decoder stop functioning, but as long as the specified voltage is supplied, the contents of cpu registers, on-chip ram, and some on-chip peripheral module registers are retained. on-chip ram contents will be further retained down to a minimum ram data retention voltage. the i/o ports go to the high-impedance state. 5.3.2 clearing standby mode standby mode is cleared by an interrupt (irq 1 or irq 0 ), wkp 7 to wkp 0 or by input at the res pin. ? clearing by interrupt when an interrupt is requested, the system clock pulse generator starts. after the time set in bits sts2 to sts0 in syscr1 has elapsed, a stable system clock signal is supplied to the entire chip, standby mode is cleared, and interrupt exception handling starts. operation resumes in active (high-speed) mode if mson = 0 in syscr2, or active (medium-speed) mode if mson = 1. standby mode is not cleared if the i bit of ccr is set to 1 or the particular interrupt is disabled in the interrupt enable register. ? clearing by res input when the res pin goes low, the system clock pulse generator starts. after the pulse generator output has stabilized, if the res pin is driven high, the cpu starts reset exception handling. since system clock signals are supplied to the entire chip as soon as the system clock pulse generator starts functioning, the res pin should be kept at the low level until the pulse generator output stabilizes. 5.3.3 oscillator settling time after standby mode is cleared bits sts2 to sts0 in syscr1 should be set as follows. ? when a crystal oscillator is used the table below gives settings for various operating frequencies. set bits sts2 to sts0 for a waiting time at least as long as the oscillation settling time.
106 table 5-4 clock frequency and settling time (times are in ms) sts2 sts1 sts0 waiting time 5 mhz 2 mhz 1 mhz 0 0 0 8,192 states 1.6384 4.096 8.192 0 0 1 16,384 states 3.2768 8.192 16.384 0 1 0 1,024 states 0.2048 0.512 1.024 0 1 1 2,048 states 0.4096 1.024 2.048 1 0 0 4,096 states 0.8192 2.048 4.096 1 0 1 2 states (not available) 0.0004 0.001 0.002 1 1 0 8 states 0.0016 0.004 0.008 1 1 1 16 states 0.0032 0.008 0.016 ? when an external clock is used sts2 = 1, sts1 = 0 and sts0 = 1 are recommended. other values can be set, but with other settings, operation may start before the standby time is over. 5.3.4 standby mode transition and pin states when a sleep instruction is executed in active (high-speed) mode or active (medium-speed) mode while bit ssby is set to 1 and bit lson is cleared to 0 in syscr1, and bit tma3 is cleared to 0 in tma, a transition is made to standby mode. at the same time, pins go to the high- impedance state (except pins for which the pull-up mos is designated as on). figure 5-2 shows the timing in this case. sleep instruction fetch internal data bus fetch of next instruction port output pins high-impedance active (high-speed) mode or active (medium-speed) mode standby mode sleep instruction execution internal processing figure 5-2 standby mode transition and pin states
107 5.3.5 notes on external input signal changes before/after standby mode 1. when external input signal changes before/after standby mode or watch mode when an external input signal such as irq or wkp is input, both the high- and low-level widths of the signal must be at least two cycles of system clock ?or subclock sub (referred to together in this section as the internal clock). as the internal clock stops in standby mode and watch mode, the width of external input signals requires careful attention when a transition is made via these operating modes. 2. when external input signals cannot be captured because internal clock stops the case of falling edge capture is illustrated in figure 5-3 as shown in the case marked "capture not possible," when an external input signal falls immediately after a transition to active (high-speed or medium-speed) mode or subactive mode, after oscillation is started by an interrupt via a different signal, the external input signal cannot be captured if the high-level width at that point is less than 2 t cyc or 2 t subcyc . 3. recommended timing of external input signals to ensure dependable capture of an external input signal, high- and low-level signal widths of at least 2 t cyc or 2 t subcyc are necessary before a transition is made to standby mode or watch mode, as shown in "capture possible: case 1." external input signal capture is also possible with the timing shown in "capture possible: case 2" and "capture possible: case 3," in which a 2 t cyc or 2 t subcyc level width is secured.
108 t cyc t subcyc operating mode or sub capture possible: case 1 capture possible: case 2 capture possible: case 3 capture not possible interrupt by different signall external input signal active (high-speed, medium-speed) mode or subactive mode active (high-speed, medium-speed) mode or subactive mode standby mode or watch mode wait for oscillation to settle t cyc t subcyc t cyc t subcyc t cyc t subcyc figure 5-3 external input signal capture when signal changes before/after standby mode or watch mode 4. input pins to which these notes apply: irq 4 to irq 1 , wkp 7 to wkp 0 , adtrg , tmic, tmif, tmig
109 5.4 watch mode 5.4.1 transition to watch mode the system goes from active or subactive mode to watch mode when a sleep instruction is executed while the ssby bit in syscr1 is set to 1 and bit tma3 in tma is set to 1. in watch mode, operation of on-chip peripheral modules is halted except for timer a, timer f, timer g, and the flex decoder. as long as a minimum required voltage is applied, the contents of cpu registers, the on-chip ram and some registers of the on-chip peripheral modules, are retained. i/o ports keep the same states as before the transition. 5.4.2 clearing watch mode watch mode is cleared by an interrupt (timer a, timer f, timer g, irq 0 , or wkp 7 to wkp 0 ) or by input at the res pin. ? clearing by interrupt when watch mode is cleared by interrupt, the mode to which a transition is made depends on the settings of lson in syscr1 and mson in syscr2. if both lson and mson are cleared to 0, transition is to active (high-speed) mode; if lson = 0 and mson = 1, transition is to active (medium-speed) mode; if lson = 1, transition is to subactive mode. when the transition is to active mode, after the time set in syscr1 bits sts2 to sts0 has elapsed, a stable clock signal is supplied to the entire chip, watch mode is cleared, and interrupt exception handling starts. watch mode is not cleared if the i bit of ccr is set to 1 or the particular interrupt is disabled in the interrupt enable register. ? clearing by res input clearing by res pin is the same as for standby mode; see 2. clearing by res pin in 5.3.2, clearing standby mode. 5.4.3 oscillator settling time after watch mode is cleared the waiting time is the same as for standby mode; see 5.3.3, oscillator settling time after standby mode is cleared. 5.4.4 notes on external input signal changes before/after watch mode see 5.3.5, notes on external input signal changes before/after standby mode.
110 5.5 subsleep mode 5.5.1 transition to subsleep mode the system goes from subactive mode to subsleep mode when a sleep instruction is executed while the ssby bit in syscr1 is cleared to 0, lson bit in syscr1 is set to 1, and tma3 bit in tma is set to 1. in subsleep mode, operation of on-chip peripheral modules other than the a/d converter and wdt is halted. as long as a minimum required voltage is applied, the contents of cpu registers, the on-chip ram and some registers of the on-chip peripheral modules are retained. i/o ports keep the same states as before the transition. 5.5.2 clearing subsleep mode subsleep mode is cleared by an interrupt (timer a, timer c, timer f, timer g, sci1, sci32, sci31, irq 4 to irq 0 , wkp 7 to wkp 0 ) or by a low input at the res pin. ? clearing by interrupt when an interrupt is requested, subsleep mode is cleared and interrupt exception handling starts. subsleep mode is not cleared if the i bit of ccr is set to 1 or the particular interrupt is disabled in the interrupt enable register. to synchronize the interrupt request signal with the subclock, up to 2/ sub (s) delay may occur after the interrupt request signal occurrence, before the interrupt exception handling start. ? clearing by res input clearing by res pin is the same as for standby mode; see 2. clearing by res pin in 5.3.2, clearing standby mode.
111 5.6 subactive mode 5.6.1 transition to subactive mode subactive mode is entered from watch mode if a timer a, timer f, timer g, irq 0 , or wkp 7 to wkp0 interrupt is requested while the lson bit in syscr1 is set to 1. from subsleep mode, subactive mode is entered if a timer a, timer c, timer f, timer g, sci1, sci31, sci32, irq 4 to irq 0 , or wkp 7 to wkp 0 interrupt is requested. a transition to subactive mode does not take place if the i bit of ccr is set to 1 or the particular interrupt is disabled in the interrupt enable register. 5.6.2 clearing subactive mode subactive mode is cleared by a sleep instruction or by a low input at the res pin. ? clearing by sleep instruction if a sleep instruction is executed while the ssby bit in syscr1 is set to 1 and tma3 bit in tma is set to 1, subactive mode is cleared and watch mode is entered. if a sleep instruction is executed while ssby = 0 and lson = 1 in syscr1 and tma3 = 1 in tma, subsleep mode is entered. direct transfer to active mode is also possible; see 5.8, direct transfer, below. ? clearing by res pin clearing by res pin is the same as for standby mode; see 2. clearing by res pin in 5.3.2, clearing standby mode. 5.6.3 operating frequency in subactive mode the operating frequency in subactive mode is set in bits sa1 and sa0 in syscr2. the choices are w /2, w /4, and w /8.
112 5.7 active (medium-speed) mode 5.7.1 transition to active (medium-speed) mode if the res pin is driven low, active (medium-speed) mode is entered. if the lson bit in syscr2 is set to 1 while the lson bit in syscr1 is cleared to 0, a transition to active (medium-speed) mode results from irq 0 , irq 1 or wkp 7 to wkp 0 interrupts in standby mode, timer a, timer f, timer g, irq 0 or wkp 7 to wkp 0 interrupts in watch mode, or any interrupt in sleep mode. a transition to active (medium-speed) mode does not take place if the i bit of ccr is set to 1 or the particular interrupt is disabled in the interrupt enable register. the cpu may operate at a 1/2 state faster timing at transition to active (medium-speed) mode. 5.7.2 clearing active (medium-speed) mode active (medium-speed) mode is cleared by a sleep instruction. ? clearing by sleep instruction a transition to standby mode takes place if the sleep instruction is executed while the ssby bit in syscr1 is set to 1, the lson bit in syscr1 is cleared to 0, and the tma3 bit in tma is cleared to 0. the system goes to watch mode if the ssby bit in syscr1 is set to 1 and bit tma3 in tma is set to 1 when a sleep instruction is executed. when both ssby and lson are cleared to 0 in syscr1 and a sleep instruction is executed, sleep mode is entered. direct transfer to active (high-speed) mode or to subactive mode is also possible. see 5.8, direct transfer, below for details. ? clearing by res pin when the res pin is driven low, a transition is made to the reset state and active (medium-speed) mode is cleared. 5.7.3 operating frequency in active (medium-speed) mode operation in active (medium-speed) mode is clocked at the frequency designated by the ma1 and ma0 bits in syscr1.
113 5.8 direct transfer 5.8.1 overview of direct transfer the cpu can execute programs in three modes: active (high-speed) mode, active (medium-speed) mode, and subactive mode. a direct transfer is a transition among these three modes without the stopping of program execution. a direct transfer can be made by executing a sleep instruction while the dton bit in syscr2 is set to 1. after the mode transition, direct transfer interrupt exception handling starts. if the direct transfer interrupt is disabled in interrupt enable register 2, a transition is made instead to sleep mode or watch mode. note that if a direct transition is attempted while the i bit in ccr is set to 1, sleep mode or watch mode will be entered, and it will be impossible to clear the resulting mode by means of an interrupt. ? direct transfer from active (high-speed) mode to active (medium-speed) mode when a sleep instruction is executed in active (high-speed) mode while the ssby and lson bits in syscr1 are cleared to 0, the mson bit in syscr2 is set to 1, and the dton bit in syscr2 is set to 1, a transition is made to active (medium-speed) mode via medium-speed sleep mode. ? direct transfer from active (medium-speed) mode to active (high-speed) mode when a sleep instruction is executed in active (medium-speed) mode while the ssby and lson bits in syscr1 are cleared to 0, the mson bit in syscr2 is cleared to 0, and the dton bit in syscr2 is set to 1, a transition is made to active (high-speed) mode via high-speed sleep mode. ? direct transfer from active (high-speed) mode to subactive mode when a sleep instruction is executed in active (high-speed) mode while the ssby and lson bits in syscr1 are set to 1, the dton bit in syscr2 is set to 1, and the tma3 bit in tma is set to 1, a transition is made to subactive mode via watch mode. ? direct transfer from subactive mode to active (high-speed) mode when a sleep instruction is executed in subactive mode while the ssby bit in syscr1 is set to 1, the lson bit in syscr1 is cleared to 0, the mson bit in syscr2 is cleared to 0, the dton bit in syscr2 is set to 1, and the tma3 bit in tma is set to 1, a transition is made directly to active (high-speed) mode via watch mode after the waiting time set in syscr1 bits sts2 to sts0 has elapsed.
114 ? direct transfer from active (medium-speed) mode to subactive mode when a sleep instruction is executed in active (medium-speed) while the ssby and lson bits in syscr1 are set to 1, the dton bit in syscr2 is set to 1, and the tma3 bit in tma is set to 1, a transition is made to subactive mode via watch mode. ? direct transfer from subactive mode to active (medium-speed) mode when a sleep instruction is executed in subactive mode while the ssby bit in syscr1 is set to 1, the lson bit in syscr1 is cleared to 0, the mson bit in syscr2 is set to 1, the dton bit in syscr2 is set to 1, and the tma3 bit in tma is set to 1, a transition is made directly to active (medium-speed) mode via watch mode after the waiting time set in syscr1 bits sts2 to sts0 has elapsed. 5.8.2 direct transition times 1. time for direct transition from active (high-speed) mode to active (medium-speed) mode a direct transition from active (high-speed) mode to active (medium-speed) mode is performed by executing a sleep instruction in active (high-speed) mode while bits ssby and lson are both cleared to 0 in syscr1, and bits mson and dton are both set to 1 in syscr2. the time from execution of the sleep instruction to the end of interrupt exception handling (the direct transition time) is given by equation (1) below. direct transition time = { (number of sleep instruction execution states) + (number of internal processing states) } (t cyc before transition) + (number of interrupt exception handling execution states) (t cyc after transition) .................................. (1) example: direct transition time = (2 + 1) 2t osc + 14 16t osc = 230t osc (when ?8 is selected as the cpu operating clock) notation: t osc : osc clock cycle time t cyc : system clock (? cycle time 2. time for direct transition from active (medium-speed) mode to active (high-speed) mode a direct transition from active (medium-speed) mode to active (high-speed) mode is performed by executing a sleep instruction in active (medium-speed) mode while bits ssby and lson are both cleared to 0 in syscr1, and bit mson is cleared to 0 and bit dton is set to 1 in syscr2. the time from execution of the sleep instruction to the end of interrupt exception handling (the direct transition time) is given by equation (2) below.
115 direct transition time = { (number of sleep instruction execution states) + (number of internal processing states) } (t cyc before transition) + (number of interrupt exception handling execution states) (t cyc after transition) .................................. (2) example: direct transition time = (2 + 1) 16t osc + 14 2t osc = 76t osc (when ?8 is selected as the cpu operating clock) notation: t osc : osc clock cycle time t cyc : system clock (? cycle time 3. time for direct transition from subactive mode to active (high-speed) mode a direct transition from subactive mode to active (high-speed) mode is performed by executing a sleep instruction in subactive mode while bit ssby is set to 1 and bit lson is cleared to 0 in syscr1, bit mson is cleared to 0 and bit dton is set to 1 in syscr2, and bit tma3 is set to 1 in tma. the time from execution of the sleep instruction to the end of interrupt exception handling (the direct transition time) is given by equation (3) below. direct transition time = { (number of sleep instruction execution states) + (number of internal processing states) } (t subcyc before transition) + { (wait time set in sts2 to sts0) + (number of interrupt exception handling execution states) } (t cyc after transition) ........................ (3) example: direct transition time = (2 + 1) 8t w + (8192 + 14) 2t osc = 24t w + 16412t osc (when ?/8 is selected as the cpu operating clock, and wait time = 8192 states) notation: t osc : osc clock cycle time t w : watch clock cycle time t cyc : system clock (? cycle time t subcyc : subclock ( sub ) cycle time
116 4. time for direct transition from subactive mode to active (medium-speed) mode a direct transition from subactive mode to active (medium-speed) mode is performed by executing a sleep instruction in subactive mode while bit ssby is set to 1 and bit lson is cleared to 0 in syscr1, bits mson and dton are both set to 1 in syscr2, and bit tma3 is set to 1 in tma. the time from execution of the sleep instruction to the end of interrupt exception handling (the direct transition time) is given by equation (4) below. direct transition time = { (number of sleep instruction execution states) + (number of internal processing states) } (t subcyc before transition) + { (wait time set in sts2 to sts0) + (number of interrupt exception handling execution states) } (t cyc after transition) ........................ (4) example: direct transition time = (2 + 1) 8t w + (8192 + 14) 16t osc = 24t w + 131296t osc (when ?/8 or ? is selected as the cpu operating clock, and wait time = 8192 states) notation: t osc : osc clock cycle time t w : watch clock cycle time t cyc : system clock (? cycle time t subcyc : subclock ( sub ) cycle time 5.8.3 notes on external input signal changes before/after direct transition 1. direct transition from active (high-speed) mode to subactive mode since the mode transition is performed via watch mode, see 5.3.5, notes on external input signal changes before/after standby mode. 2. direct transition from active (medium-speed) mode to subactive mode since the mode transition is performed via watch mode, see 5.3.5, notes on external input signal changes before/after standby mode. 3. direct transition from subactive mode to active (high-speed) mode since the mode transition is performed via watch mode, see 5.3.5, notes on external input signal changes before/after standby mode. 4. direct transition from subactive mode to active (medium-speed) mode since the mode transition is performed via watch mode, see 5.3.5, notes on external input signal changes before/after standby mode.
117 5.9 module standby mode 5.9.1 setting module standby mode module standby mode is set for individual peripheral functions. all the on-chip peripheral modules can be placed in module standby mode. when a module enters module standby mode, the system clock supply to the module is stopped and operation of the module halts. this state is identical to standby mode. module standby mode is set for a particular module by setting the corresponding bit to 0 in clock stop register 1 (ckstpr1) or clock stop register 2 (ckstpr2). (see table 5-5.) 5.9.2 clearing module standby mode module standby mode is cleared for a particular module by setting the corresponding bit to 1 in clock stop register 1 (ckstpr1) or clock stop register 2 (ckstpr2). (see table 5-5.) following a reset, clock stop register 1 (ckstpr1) and clock stop register 2 (ckstpr2) are both initialized to h'ff.
118 table 5-5 setting and clearing module standby mode by clock stop register register name bit name operation ckstpr1 tackstp 1 timer a module standby mode is cleared 0 timer a is set to module standby mode tcckstp 1 timer c module standby mode is cleared 0 timer c is set to module standby mode tfckstp 1 timer f module standby mode is cleared 0 timer f is set to module standby mode tgckstp 1 timer g module standby mode is cleared 0 timer g is set to module standby mode adckstp 1 a/d converter module standby mode is cleared 0 a/d converter is set to module standby mode s1ckstp 1 sci1 module standby mode is cleared 0 sci1 is set to module standby mode s32ckstp 1 sci32 module standby mode is cleared 0 sci32 is set to module standby mode s31ckstp 1 sci31 module standby mode is cleared 0 sci31 is set to module standby mode table 5-5 setting and clearing module standby mode by clock stop register (cont) register name bit name operation ckstpr2 wdckstp 1 watchdog timer module standby mode is cleared 0 watchdog timer is set to module standby mode note: for details of module operation, see the sections on the individual modules.
119 section 6 rom 6.1 overview the h8/3935 and h8/3935r have 40 kbytes of mask rom, the h8/3936 and h8/3936r have 48 kbytes of mask rom, and the h8/3937 and h8/3937r have 60 kbytes of mask rom on-chip. the rom is connected to the cpu by a 16-bit data bus, allowing high-speed two-state access for both byte data and word data. the h8/3937 and h8/3937r have a ztat version with 60-kbyte prom. 6.1.1 block diagram figure 6-1 shows a block diagram of the on-chip rom. h'9ffe h'9fff internal data bus (upper 8 bits) internal data bus (lower 8 bits) even-numbered address odd-numbered address h'9ffe h'0002 h'0000 h'0000 h'0002 h'0001 h'0003 on-chip rom figure 6-1 rom block diagram (h8/3935, h8/3935r)
120 6.2 prom mode 6.2.1 setting to prom mode if the on-chip rom is prom, setting the chip to prom mode stops operation as a microcontroller and allows the prom to be programmed in the same way as the standard hn27c101 eprom. however, page programming is not supported. table 6-1 shows how to set the chip to prom mode. table 6-1 setting to prom mode pin name setting test high level p9 0 , pb 4 /an 4 low level p9 1 , pb 5 /an 5 p9 2 , pb 6 /an 6 high level 6.2.2 socket adapter pin arrangement and memory map a standard prom programmer can be used to program the prom. a socket adapter is required for conversion to 32 pins, as listed in table 6-2. figure 6-2 shows the pin-to-pin wiring of the socket adapter. figure 6-3 shows a memory map. table 6-2 socket adapter package socket adapter model (manufacturer) 100-pin (tfp-100b) h7393bt100d3201 (data-i/o) me3937esnsih (minato) 100-pin (tfp-100g) h7393gt100d3201 (data-i/o) me3937esmsih (minato)
121 tfp-100b, tfp-100g pin 13 43 44 45 46 47 48 49 50 94 93 92 91 90 89 88 87 53 34 55 56 57 58 59 18 19 60 54 17 12, 52 99 86 85 97 15 16 20 6 11, 51 8 95 96 83 72 71 70 4 5 81 hn27c101 (32-pin) 1 13 14 15 17 18 19 20 21 12 11 10 9 8 7 6 5 27 26 23 25 4 28 29 3 2 22 24 31 32 16 res figure 6-2 socket adapter pin correspondence (with hn27c101)
122 address in mcu mode address in prom mode h'0000 h'0000 h'1ffff h'edff h'edff on-chip prom uninstalled area * note: * the output data is not guaranteed if this address area is read in prom mode. therefore, when programming with a prom programmer, be sure to specify addresses from h'0000 to h'edff. if programming is inadvertently performed from h'ee00 onward, it may not be possible to continue prom programming and verification. when programming, h'ff should be set as the data in this address area (h'ee00 to h'1ffff). figure 6-3 h8/3937 and h8/3937r memory map in prom mode
123 6.3 programming the write, verify, and other modes are selected as shown in table 6-3 in prom mode. table 6-3 mode selection in prom mode (h8/3937, h8/3937r) pins mode ce oe pgm v pp v cc eo 7 to eo 0 ea 16 to ea 0 write l h l v pp v cc data input address input verify l l h v pp v cc data output address input programming l l l v pp v cc hig h impe da nc e address input disabled l h h hl l hh h notation: l: low level h: high level v pp :v pp level v cc :v cc level the specifications for writing and reading are identical to those for the standard hn27c101 eprom. however, page programming is not supported, and so page programming mode must not be set. a prom programmer that only supports page programming mode cannot be used. when selecting a prom programmer, ensure that it supports high-speed, high-reliability byte-by-byte programming. also, be sure to specify addresses from h'0000 to h'edff. 6.3.1 writing and verifying an efficient, high-speed, high-reliability method is available for writing and verifying the prom data. this method achieves high speed without voltage stress on the device and without lowering the reliability of written data. the basic flow of this high-speed, high-reliability programming method is shown in figure 6-4.
124 start set write/verify mode v = 6.0 v 0.25 v, v = 12.5 v 0.3 v cc pp address = 0 n = 0 n + 1 n pw verify write time t = 3n ms opw last address? set read mode v = 5.0 v 0.25 v, v = v cc pp cc read all addresses? end error n 25 < address + 1 address no yes no go go yes no no go go write time t = 0.2 ms 5% figure 6-4 high-speed, high-reliability programming flow chart
125 table 6-4 and table 6-5 give the electrical characteristics in programming mode. table 6-4 dc characteristics (conditions: v cc = 6.0 v 0.25 v, v pp = 12.5 v 0.3 v, v ss = 0 v, t a = 25 c ? c) item symbol min typ max unit test condi t i on input high- level voltage eo 7 to eo 0 , ea 16 to ea 0 oe , ce , pgm v ih 2.4 v cc + 0.3 v input low- level voltage eo 7 to eo 0 , ea 16 to ea 0 oe , ce , pgm v il ?.3 0.8 v output high- level voltage eo 7 to eo 0 v oh 2.4 v i oh = ?00 ? output low level voltage eo 7 to eo 0 v ol 0.45 v i ol = 0.8 ma input leakage current eo 7 to eo 0 , ea 16 to ea 0 oe , ce , pgm |i li | 2 ? v in = 5.25 v/0.5 v v cc current i cc 40 ma v pp current i pp 40 ma
126 table 6-5 ac characteristics (conditions: v cc = 6.0 v 0.25 v, v pp = 12.5 v 0.3 v, t a = 25 c ? c) item symbol min typ max unit test condition address setup time t as 2 s figure 6-5 * 1 oe setup time t oes 2s data setup time t ds 2s address hold time t ah 0s data hold time t dh 2s data output disable time t df * 2 130 ? v pp setup time t vps 2s programming pulse width t pw 0.19 0.20 0.21 ms pgm pulse width for overwrite programming t opw * 3 0.19 5.25 ms ce setup time t ces 2s v cc setup time t vcs 2s data output delay time t oe 0 200 ns notes: 1. input pulse level: 0.45 v to 2.4 v input rise time/fall time 20 ns timing reference levels input: 0.8 v, 2.0 v output: 0.8 v, 2.0 v 2. t df is defined at the point at which the output is floating and the output level cannot be read. 3. t opw is defined by the value given in figure 6-4, high-speed, high-reliability programming flow chart.
127 figure 6-5 shows a prom write/verify timing diagram. write input data output data verify address data v pp v pp t as t ah t ds t dh t df t oe t oes t pw t opw * t vps t vcs t ces v cc v cc ce pgm oe v cc +1 v cc note: * t opw is defined by the value shown in figure 6.4, high-speed, high-reliability programming flowchart. figure 6-5 prom write/verify timing
128 6.3.2 programming precautions ? ? ? ? ? ?
129 6.4 reliability of programmed data a highly effective way to improve data retention characteristics is to bake the programmed chips at 150 c, then screen them for data errors. this procedure quickly eliminates chips with prom memory cells prone to early failure. figure 6-6 shows the recommended screening procedure. program chip and verify programmed data bake chip for 24 to 48 hours at 125 figure 6-6 recommended screening procedure if a series of programming errors occurs while the same prom programmer is in use, stop programming and check the prom programmer and socket adapter for defects. please inform hitachi of any abnormal conditions noted during or after programming or in screening of program data after high-temperature baking.
130
131 section 7 ram 7.1 overview the h8/3937 series and h8/3937r series have 2 kbytes of high-speed static ram on-chip. the ram is connected to the cpu by a 16-bit data bus, allowing high-speed 2-state access for both byte data and word data. 7.1.1 block diagram figure 7-1 shows a block diagram of the on-chip ram. h'ff7e h'ff7f internal data bus (upper 8 bits) internal data bus (lower 8 bits) even-numbered address odd-numbered address h'ff7e h'f782 h'f780 h'f780 h'f782 h'f781 h'f783 on-chip ram figure 7-1 ram block diagram (h8/3935, h8/3935r)
132
133 section 8 i/o ports 8.1 overview the h8/3937 series and h8/3937r series are provided with six 8-bit i/o ports, two 4-bit i/o ports, one 3-bit i/o port, and one 8-bit input-only port. also provided are one internal 5-bit i/o port and one internal 1-bit input-only port capable of interfacing to the on-chip flex decoder. table 8-1 indicates the functions of each port. each port has of a port control register (pcr) that controls input and output, and a port data register (pdr) for storing output data. input or output can be assigned to individual bits. see 2.9.2, notes on bit manipulation, for information on executing bit-manipulation instructions to write data in pcr or pdr. block diagrams of each port are given in appendix c, i/o port block diagrams table 8-1 port functions port description pins and functions other functions function switching registers port 1 ? 8-bit i/o port ? mos input pull-up option p1 7 to p1 5 / irq 3 to irq 1 /tmif, tmic external interrupts 3 to 1 timer event interrupts tmif, tmic pmr1 tcrf, tmc p1 4 / irq 4 / adtrg external interrupt 4 and a/d converter external trigger pmr1, amr p1 3 /tmig timer g input capture input pmr1 p1 2 , p1 1 / tmofh, tmofl timer f output compare output pmr1 p1 0 /tmow timer a clock output pmr1 port 2 * 1 ? 5-bit i/o internal port p2 0 /sck 1 p2 1 /si 1 p2 2 /so 1 sci1 data output (so 1 ), data input (si 1 ), clock input/output (sck 1 ) pmr2 p2 4 , p2 3 none
134 port description pins and functions other functions function switching registers port 3 ? 8-bit i/o port ? mos input pull-up option p3 7 p3 6 p3 5 /txd 31 p3 4 /rxd 31 p3 3 /sck 31 sci31 data output (txd 31 ), data input (rxd 31 ), clock input/output (sck 31 ) pmr3 scr31 smr31 p3 2 / reso p3 1 /ud p3 0 reset output, timer c count- up/down select input pmr3 port 4 ? 1-bit input internal port p4 3 / irq 0 * 2 internal irq interrupt 0 pmr3 ? 3-bit i/o port p4 2 /txd 32 p4 1 /rxd 32 p4 0 /sck 32 sci32 data output (txd 32 ), data input (rxd 32 ), clock input/output (sck 32 ) scr32 smr32 port 5 ? 8-bit i/o port ? mos input pull-up option p5 7 to p5 0 / wkp 7 to wkp 0 wakeup input ( wkp 7 to wkp 0 ) pmr5 port 6 ? 8-bit i/o port ? mos input pull-up option p6 7 to p6 0 port 7 ? 8-bit i/o port p7 7 to p7 0 port 8 ? 8-bit i/o port p8 7 to p8 0 port 9 ? 4-bit i/o port p9 3 to p9 0 port a ? 4-bit i/o port pa 3 to pa 0 port b ? 8-bit input port pb 7 to pb 0 / an 7 to an 0 a/d converter analog input amr notes: 1. internal i/o port for interfacing to the flex decoder. 2. internal input port for interfacing to the flex decoder.
135 8.2 port 1 8.2.1 overview port 1 is an 8-bit i/o port. figure 8-1 shows its pin configuration. p1 /irq /tmif p1 /irq p1 /irq /tmic p1 / irq adtrg figure 8-1 port 1 pin configuration 8.2.2 register configuration and description table 8-2 shows the port 1 register configuration. table 8-2 port 1 registers name abbrev. r/w initial value address port data register 1 pdr1 r/w h'00 h'ffd4 port control register 1 pcr1 w h'00 h'ffe4 port pull-up control register 1 pucr1 r/w h'00 h'ffe0 port mode register 1 pmr1 r/w h'00 h'ffc8
136 1. port data register 1 (pdr1) bit initial value read/write 7 p1 0 r/w 6 p1 0 r/w 5 p1 0 r/w 4 p1 0 r/w 3 p1 0 r/w 0 p1 0 r/w 2 p1 0 r/w 1 p1 0 r/w 76543210 pdr1 is an 8-bit register that stores data for port 1 pins p1 7 to p1 0 . if port 1 is read while pcr1 bits are set to 1, the values stored in pdr1 are read, regardless of the actual pin states. if port 1 is read while pcr1 bits are cleared to 0, the pin states are read. upon reset, pdr1 is initialized to h'00. 2. port control register 1 (pcr1) bit initial value read/write 7 pcr1 0 w 6 pcr1 0 w 5 pcr1 0 w 4 pcr1 0 w 3 pcr1 0 w 0 pcr1 0 w 2 pcr1 0 w 1 pcr1 0 w 76543210 pcr1 is an 8-bit register for controlling whether each of the port 1 pins p1 7 to p1 0 functions as an input pin or output pin. setting a pcr1 bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. the settings in pcr1 and in pdr1 are valid only when the corresponding pin is designated in pmr1 as a general i/o pin. upon reset, pcr1 is initialized to h'00. pcr1 is a write-only register, which is always read as all 1s. 3. port pull-up control register 1 (pucr1) bit initial value read/write 7 pucr1 0 r/w 6 pucr1 0 r/w 5 pucr1 0 r/w 4 pucr1 0 r/w 3 pucr1 0 r/w 0 pucr1 0 r/w 2 pucr1 0 r/w 1 pucr1 0 r/w 7 65 4 32 10 pucr1 controls whether the mos pull-up of each of the port 1 pins p1 7 to p1 0 is on or off. when a pcr1 bit is cleared to 0, setting the corresponding pucr1 bit to 1 turns on the mos pull-up for the corresponding pin, while clearing the bit to 0 turns off the mos pull-up. upon reset, pucr1 is initialized to h'00.
137 4. port mode register 1 (pmr1) b it i nitial value r ead/write 7 irq3 0 r/w 6 irq2 0 r/w 5 irq1 0 r/w 4 irq4 0 r/w 3 tmig 0 r/w 0 tmow 0 r/w 2 tmofh 0 r/w 1 tmofl 0 r/w pmr1 is an 8-bit read/write register, controlling the selection of pin functions for port 1 pins. upon reset, pmr1 is initialized to h'00. bit 7: p1 7 / irq irq irq bit 7 irq3 description 0 functions as p1 7 i/o pin (initial value) 1 functions as irq irq bit 6: p1 6 / irq irq irq bit 6 irq2 description 0 functions as p1 6 i/o pin (initial value) 1 functions as irq irq bit 5: p1 5 / irq irq irq bit 5 irq1 description 0 functions as p1 5 i/o pin (initial value) 1 functions as irq irq
138 bit 4: p1 4 / irq adtrg irq adtrg irq adtrg bit 4 irq4 description 0 functions as p1 4 i/o pin (initial value) 1 functions as irq adtrg adtrg bit 3: p1 3 /tmig pin function switch (tmig) this bit selects whether pin p1 3 /tmig is used as p1 3 or as tmig. bit 3 tmig description 0 functions as p1 3 i/o pin (initial value) 1 functions as tmig input pin bit 2: p1 2 /tmofh pin function switch (tmofh) this bit selects whether pin p1 2 /tmofh is used as p1 2 or as tmofh. bit 2 tmofh description 0 functions as p1 2 i/o pin (initial value) 1 functions as tmofh output pin bit 1: p1 1 /tmofl pin function switch (tmofl) this bit selects whether pin p1 1 /tmofl is used as p1 1 or as tmofl. bit 1 tmofl description 0 functions as p1 1 i/o pin (initial value) 1 functions as tmofl output pin
139 bit 0: p1 0 /tmow pin function switch (tmow) this bit selects whether pin p1 0 /tmow is used as p10 or as tmow. bit 0 tmow description 0 functions as p1 0 i/o pin (initial value) 1 functions as tmow output pin
140 8.2.3 pin functions table 8-3 shows the port 1 pin functions. table 8-3 port 1 pin functions pin pin functions and selection method p1 7 / irq irq irq irq irq irq irq irq irq adtrg irq irq adtrg adtrg
141 pin pin functions and selection method p1 3 /tmig the pin function depends on bit tmig in pmr1 and bit pcr13 in pcr1. tmig 0 1 pcr1 3 01 * pin function p1 3 input pin p1 3 output pin tmig input pin p1 2 /tmofh the pin function depends on bit tmofh in pmr1 and bit pcr1 2 in pcr1. tmofh 0 1 pcr1 2 01 * pin function p1 2 input pin p1 2 output pin tmofh output pin p1 1 /tmofl the pin function depends on bit tmofl in pmr1 and bit pcr1 1 in pcr1. tmofl 0 1 pcr1 1 01 * pin function p1 1 input pin p1 1 output pin tmofl output pin p1 0 /tmow the pin function depends on bit tmow in pmr1 and bit pcr1 0 in pcr1. tmow 0 1 pcr1 0 01 * pin function p1 0 input pin p1 0 output pin tmow output pin * : don t care
142 8.2.4 pin states table 8-4 shows the port 1 pin states in each operating mode. table 8-4 port 1 pin states pins reset sleep subsleep standby watch subactive active p1 7 / irq irq irq irq adtrg 8.2.5 mos input pull-up port 1 has a built-in mos input pull-up function that can be controlled by software. when a pcr1 bit is cleared to 0, setting the corresponding pucr1 bit to 1 turns on the mos input pull-up for that pin. the mos input pull-up function is in the off state after a reset. pcr1 n 00 1 pucr1 n 01 * mos input pull-up off on off (n = 7 to 0) * : don t care
143 8.3 port 2 [chip internal i/o port] 8.3.1 overview port 2 is a 5-bit i/o internal port. figure 8-2 shows its functional configuration. port 2 is an internal function that performs interfacing to the flex decoder incorporated in the chip. it cannot be connected to an ic outside the chip. p2 4 p2 3 p2 2 /so 1 p2 1 /si 1 p2 0 /sck 1 port 2 flex decoder reset ss figure 8-2 port 2 functional configuration 8.3.2 register configuration and description table 8-5 shows the port 2 register configuration. table 8-5 port 2 registers name abbrev. r/w initial value address port data register 2 pdr2 r/w h'00 h'ffd5 port control register 2 pcr2 w h'00 h'ffe5 port mode register 2 pmr2 r/w h'd8 h'ffc9 port mode register 4 pmr4 r/w h'00 h'ffcb
144 1. port data register 2 (pdr2) bit initial value read/write 7 0 6 0 5 0 4 p2 4 0 r/w 3 p2 3 0 r/w 0 p2 0 0 r/w 2 p2 2 0 r/w 1 p2 1 0 r/w pdr2 is an 8-bit register that stores data for port 2 pins p2 4 to p2 0 . if port 2 is read while pcr2 bits are set to 1, the values stored in pdr2 are read directly. do not read port 2 while pcr2 bits are cleared to 0. upon reset, pdr2 is initialized to h'00. 2. port control register 2 (pcr2) bit initial value read/write 7 1 6 1 5 1 4 pcr2 4 0 w 3 pcr2 3 0 w 0 pcr2 0 0 w 2 pcr2 2 0 w 1 pcr2 1 0 w pcr2 is an 8-bit register for controlling whether each of port 2 pins p2 4 to p2 0 functions as an input pin or output pin. setting a pcr2 bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. the settings in pcr2 and pdr2 are valid only when the corresponding pin is designated in pmr2 as a general i/o pin. upon reset, pcr2 is initialized to h'00. pcr2 is a write-only register, which is always read as all 1s. 3. port mode register 2 (pmr2) bit initial value read/write 7 1 6 1 5 pof1 0 r/w 4 1 3 1 0 sck1 0 r/w 2 so1 0 r/w 1 si1 0 r/w pmr2 is an 8-bit read/write register that controls the selection of pin functions for port 2 pins p2 0 , p2 1 , and p2 2 , and the pmos on/off state for the p2 2 /so 1 pin. bit 5, the p2 2 /so 1 pin pmos control bit (pof1), should be cleared to 0. upon reset, pmr2 is initialized to h'd8.
145 bits 7, 6, 4, and 3: reserved bits bits 7, 6, 4, and 3 are reserved; they are always read as 1 and cannot be modified. bit 5: p2 2 /so 1 pin pmos control (pof1) this bit controls the on/off state of the p2 2 /so 1 pin pmos. this bit should be cleared to 0. bit 5 pof1 description 0 cmos setting (initial value) 1 nmos open-drain setting bit 2: p2 2 /so 1 pin function switch (so1) this bit selects whether pin p2 2 /so 1 is used as p2 2 or as so 1 . bit 2 so1 description 0 functions as p2 2 i/o pin (initial value) 1 functions as so 1 output pin bit 1: p2 1 /si 1 pin function switch (si1) this bit selects whether pin p2 1 /si 1 is used as p2 1 or as si 1 . bit 1 si1 description 0 functions as p2 1 i/o pin (initial value) 1 functions as si 1 input pin bit 0: p2 0 /sck 1 pin function switch (sck1) this bit selects whether pin p2 0 /sck 1 is used as p2 0 or as sck 1 . bit 0 sck1 description 0 functions as p2 0 i/o pin (initial value) 1 functions as sck 1 i/o pin
146 4. port mode register 4 (pmr4) bit initial value read/write 7 0 6 0 5 0 4 nmod4 0 r/w 3 nmod3 0 r/w 0 nmod0 0 r/w 2 nmod2 0 r/w 1 nmod1 0 r/w pmr4 is an 8-bit read/write register that controls whether individual port 2 pins are set as cmos or nmos open-drain when 1 is set in pcr. a 0 setting should be used for this function. upon reset, pmr4 is initialized to h'00. bit n: nmos open-drain output select (nmodn) these bits select nmos open-drain when pin p2 n is used as an output pin. these bits should be cleared to 0. bit n nmodn description 0 cmos setting (initial value) 1 nmos open-drain setting (n = 4 to 0)
147 8.3.3 function table 8-6 shows the port 2 functions. table 8-6 port 2 functions functions functions and selection method p2 4 , p2 3 the function depends on the corresponding bit in pcr2. (n = 4 or 3) pcr2 n 01 function p2 n input p2 n output p2 2 /so 1 the function depends on bit so1 in pmr2 and bit pcr2 2 in pcr2. so1 0 1 pcr2 2 01 * function p2 2 input p2 2 output so 1 output p2 1 /si 1 the function depends on bit si1 in pmr2 and bit pcr2 1 in pcr2. si1 0 1 pcr2 1 01 * function p2 1 input p2 1 output si 1 input p2 0 /sck 1 the function depends on bit sck1 in pmr2 and bit pcr2 0 in pcr2. sck1 0 1 pcr2 0 01 * function p2 0 input p2 0 output sck 1 i/o * : don t care 8.3.4 states table 8-7 shows the port 2 states in each operating mode. table 8-7 port 2 states functions reset sleep subsleep standby watch subactive active p2 4 low retains retains retains retains functional functional p2 3 high previous previous previous previous p2 2 /so 1 p2 1 /si 1 p2 0 /sck 1 low state state state state
148 8.4 port 3 8.4.1 overview port 3 is an 8-bit i/o port, configured as shown in figure 8-3. p3 p3 p3 /txd 7 6 5 port 3 31 p3 /rxd p3 /sck p3 /reso 4 3 2 31 31 p3 /ud p3 1 0 figure 8-3 port 3 pin configuration 8.4.2 register configuration and description table 8-8 shows the port 3 register configuration. table 8-8 port 3 registers name abbrev. r/w initial value address port data register 3 pdr3 r/w h'00 h'ffd6 port control register 3 pcr3 w h'00 h'ffe6 port pull-up control register 3 pucr3 r/w h'00 h'ffe1 port mode register 3 pmr3 r/w h'04 h'ffca
149 1. port data register 3 (pdr3) b it i nitial value r ead/write 7 p3 0 r/w 6 p3 0 r/w 5 p3 0 r/w 4 p3 0 r/w 3 p3 0 r/w 0 p3 0 r/w 2 p3 0 r/w 1 p3 0 r/w 210 54 76 3 pdr3 is an 8-bit register that stores data for port 3 pins p3 7 to p3 0 . if port 3 is read while pcr3 bits are set to 1, the values stored in pdr3 are read, regardless of the actual pin states. if port 3 is read while pcr3 bits are cleared to 0, the pin states are read. upon reset, pdr3 is initialized to h'00. 2. port control register 3 (pcr3) b it i nitial value r ead/write 7 pcr3 0 w 6 pcr3 0 w 5 pcr3 0 w 4 pcr3 0 w 3 pcr3 0 w 0 pcr3 0 w 2 pcr3 0 w 1 pcr3 0 w 21 0 54 3 76 pcr3 is an 8-bit register for controlling whether each of the port 3 pins p3 7 to p3 0 functions as an input pin or output pin. setting a pcr3 bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. the settings in pcr3 and in pdr3 are valid only when the corresponding pin is designated in pmr3 as a general i/o pin. upon reset, pcr3 is initialized to h'00. pcr3 is a write-only register, which is always read as all 1s. 3. port pull-up control register 3 (pucr3) b it i nitial value r ead/write 7 pucr3 0 r/w 6 pucr3 0 r/w 5 pucr3 0 r/w 4 pucr3 0 r/w 3 pucr3 0 r/w 0 pucr3 0 r/w 2 pucr3 0 r/w 1 pucr3 0 r/w 2 10 5 43 76 pucr3 controls whether the mos pull-up of each of the port 3 pins p3 7 to p3 0 is on or off. when a pcr3 bit is cleared to 0, setting the corresponding pucr3 bit to 1 turns on the mos pull-up for the corresponding pin, while clearing the bit to 0 turns off the mos pull-up. upon reset, pucr3 is initialized to h'00.
150 4. port mode register 3 (pmr3) bit initial value read/write 7 0 6 0 5 wdcks 0 r/w 4 ncs 0 r/w 3 irq0 0 r/w 0 0 2 reso 1 r/w 1 ud 0 r/w pmr3 is an 8-bit read/write register, controlling the selection of pin functions for port 3 pins. upon reset, pmr3 is initialized to h'04. bits 7, 6, and 0: reserved bits these bits are reserved: they are always read as 0 and cannot be modified. bit 5: watchdog timer source clock select (wdcks) this bit selects the watchdog timer source clock. bit 5 wdcks description 0 /8192 selected (initial value) 1 w/32 selected bit 4: tmig noise canceler select (ncs) this bit controls the noise canceler for the input capture input signal (tmig). bit 4 ncs description 0 noise cancellation function not used (initial value) 1 noise cancellation function used bit 3: p4 3 / irq irq irq bit 3 irq0 description 0 functions as p4 3 input (initial value) 1 functions as irq
151 bit 2: p3 2 / reso reso reso bit 2 reso description 0 functions as p3 2 i/o pin 1 functions as reso bit 1: p3 1 /ud pin function switch (ud) this bit selects whether pin p3 1 /ud is used as p3 1 or as ud. bit 1 ud description 0 functions as p3 1 i/o pin (initial value) 1 functions as ud input pin 8.4.3 pin functions table 8-9 shows the port 3 pin functions. table 8-9 port 3 pin functions pin pin functions and selection method p3 7 , p3 6 , p3 0 the pin function depends on bit pcr3n in pcr3. (n=7, 6, 0) pcr3 n 01 pin function p3 n input pin p3 n output pin p3 5 /txd 31 the pin function depends on bit te in scr31, bit spc31 in spcr, and bit pcr3 5 in pcr3. spc31 0 1 te 0 1 pcr3 5 01 * pin function p3 5 input pin p3 5 output pin txd 31 output pin p3 4 /rxd 31 the pin function depends on bit re in scr31 and bit pcr3 4 in pcr3. re 0 1 pcr3 4 01 * pin function p3 4 input pin p3 4 output pin rxd 31 input pin
152 pin pin functions and selection method p3 3 /sck 31 the pin function depends on bits cke1, cke0, and smr31 in scr31 and bit pcr3 3 in pcr3. cke1 0 1 cke0 0 1 * com3 1 01 ** pcr3 3 01 ** pin function p3 3 input pin p3 3 output pin sck 31 output pin sck 31 input pin p3 2 / reso t care
153 8.4.4 pin states table 8-10 shows the port 3 pin states in each operating mode. table 8-10 port 3 pin states pins reset sleep subsleep standby watch subactive active p3 7 p3 6 p3 5 /txd 31 p3 4 /rxd 31 p3 3 /sck 31 high- impedance retains previous state retains previous state high- impedance * retains previous state functional functional p3 2 / reso 8.4.5 mos input pull-up port 3 has a built-in mos input pull-up function that can be controlled by software. when a pcr3 bit is cleared to 0, setting the corresponding pucr3 bit to 1 turns on the mos pull-up for that pin. the mos pull-up function is in the off state after a reset. pcr3 n 00 1 pucr3 n 01 * mos input pull-up off on off (n = 7 to 0) * : don t care
154 8.5 port 4* note: * p4 3 / irq 8.5.1 overview port 4 is a 3-bit i/o port and 1-bit input internal port, configured as shown in figure 8-4. p4 3 / irq decoder incorporated in the chip. it cannot be connected to an ic outside the chip. p4 p4 p4 p4 /irq 0 /txd 32 /rxd 32 /sck 32 3 2 1 0 port 4 flex decoder ready figure 8-4 port 4 pin configuration 8.5.2 register configuration and description table 8-11 shows the port 4 register configuration. table 8-11 port 4 registers name abbrev. r/w initial value address port data register 4 pdr4 r/w h'f8 h'ffd7 port control register 4 pcr4 w h'f8 h'ffe7
155 1. port data register 4 (pdr4) b it i nitial value r ead/write 7 1 6 1 5 1 4 1 3 p4 1 r 0 p4 0 r/w 2 p4 0 r/w 1 p4 0 r/w 3210 pdr4 is an 8-bit register that stores data for port 4 pins p4 2 to p4 0 . if port 4 is read while pcr4 bits are set to 1, the values stored in pdr4 are read, regardless of the actual pin states. if port 4 is read while pcr4 bits are cleared to 0, the pin states are read. upon reset, pdr4 is initialized to h'f8. 2. port control register 4 (pcr4) b it i nitial value r ead/write 7 1 6 1 5 1 4 1 3 1 0 pcr4 0 w 2 pcr4 0 w 1 pcr4 0 w 210 pcr4 is an 8-bit register for controlling whether each of port 4 pins p4 2 to p4 0 functions as an input pin or output pin. setting a pcr4 bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. pcr4 and pdr4 settings are valid when the corresponding pins are designated for general-purpose input/output by scr3-2. upon reset, pcr4 is initialized to h'f8. pcr4 is a write-only register, which always reads all 1s.
156 8.5.3 pin functions table 8-12 shows the port 4 pin functions. table 8-12 port 4 pin functions pin pin functions and selection method p4 3 / irq irq t care
157 8.5.4 pin states table 8-13 shows the port 4 pin states in each operating mode. table 8-13 port 4 pin states pins reset sleep subsleep standby watch subactive active p4 3 / irq
158 8.6 port 5 8.6.1 overview port 5 is an 8-bit i/o port, configured as shown in figure 8-5. p5 7 / wkp wkp wkp wkp wkp wkp wkp wkp figure 8-5 port 5 pin configuration 8.6.2 register configuration and description table 8-14 shows the port 5 register configuration. table 8-14 port 5 registers name abbrev. r/w initial value address port data register 5 pdr5 r/w h'00 h'ffd8 port control register 5 pcr5 w h'00 h'ffe8 port pull-up control register 5 pucr5 r/w h'00 h'ffe2 port mode register 5 pmr5 r/w h'00 h'ffcc
159 1. port data register 5 (pdr5) b it i nitial value r ead/write 7 p5 0 r/w 6 p5 0 r/w 5 p5 0 r/w 4 p5 0 r/w 3 p5 0 r/w 0 p5 0 r/w 2 p5 0 r/w 1 p5 0 r/w 76543210 pdr5 is an 8-bit register that stores data for port 5 pins p5 7 to p5 0 . if port 5 is read while pcr5 bits are set to 1, the values stored in pdr5 are read, regardless of the actual pin states. if port 5 is read while pcr5 bits are cleared to 0, the pin states are read. upon reset, pdr5 is initialized to h'00. 2. port control register 5 (pcr5) b it i nitial value r ead/write 7 pcr5 0 w 6 pcr5 0 w 5 pcr5 0 w 4 pcr5 0 w 3 pcr5 0 w 0 pcr5 0 w 2 pcr5 0 w 1 pcr5 0 w 76543210 pcr5 is an 8-bit register for controlling whether each of the port 5 pins p5 7 to p5 0 functions as an input pin or output pin. setting a pcr5 bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. pcr5 and pdr5 settings are valid when the corresponding pins are designated for general-purpose input/output by pmr5. upon reset, pcr5 is initialized to h'00. pcr5 is a write-only register, which is always read as all 1s. 3. port pull-up control register 5 (pucr5) b it i nitial value r ead/write 7 pucr5 0 r/w 6 pucr5 0 r/w 5 pucr5 0 r/w 4 pucr5 0 r/w 3 pucr5 0 r/w 0 pucr5 0 r/w 2 pucr5 0 r/w 1 pucr5 0 r/w 76543210 pucr5 controls whether the mos pull-up of each of port 5 pins p5 7 to p5 0 is on or off. when a pcr5 bit is cleared to 0, setting the corresponding pucr5 bit to 1 turns on the mos pull-up for the corresponding pin, while clearing the bit to 0 turns off the mos pull-up. upon reset, pucr5 is initialized to h'00.
160 4. port mode register 5 (pmr5) bit initial value read/write 7 wkp 7 0 r/w 6 wkp 6 0 r/w 5 wkp 5 0 r/w 4 wkp 4 0 r/w 3 wkp 3 0 r/w 0 wkp 0 0 r/w 2 wkp 2 0 r/w 1 wkp 1 0 r/w pmr5 is an 8-bit read/write register, controlling the selection of pin functions for port 5 pins. upon reset, pmr5 is initialized to h'00. bit n: p5 n / wkp wkp bit n wkpn description 0 functions as p5 n i/o pin (initial value) 1 functions as wkp 8.6.3 pin functions table 8-15 shows the port 5 pin functions. table 8-15 port 5 pin functions pin pin functions and selection method p5 7 / wkp wkp wkp t care
161 8.6.4 pin states table 8-16 shows the port 5 pin states in each operating mode. table 8-16 port 5 pin states pins reset sleep subsleep standby watch subactive active p5 7 / wkp wkp 8.6.5 mos input pull-up port 5 has a built-in mos input pull-up function that can be controlled by software. when a pcr5 bit is cleared to 0, setting the corresponding pucr5 bit to 1 turns on the mos pull-up for that pin. the mos pull-up function is in the off state after a reset. pcr5 n 00 1 pucr5 n 01 * mos input pull-up off on off (n = 7 to 0) * : don t care
162 8.7 port 6 8.7.1 overview port 6 is an 8-bit i/o port. the port 6 pin configuration is shown in figure 8-6. p6 7 p6 6 p6 5 p6 4 p6 3 p6 2 p6 1 p6 0 port 6 figure 8-6 port 6 pin configuration 8.7.2 register configuration and description table 8-17 shows the port 6 register configuration. table 8-17 port 6 registers name abbrev. r/w initial value address port data register 6 pdr6 r/w h'00 h'ffd9 port control register 6 pcr6 w h'00 h'ffe9 port pull-up control register 6 pucr6 r/w h'00 h'ffe3
163 1. port data register 6 (pdr6) b it i nitial value r ead/write 7 p6 0 r/w 6 p6 0 r/w 5 p6 0 r/w 4 p6 0 r/w 3 p6 0 r/w 0 p6 0 r/w 2 p6 0 r/w 1 p6 0 r/w 210 54 76 3 pdr6 is an 8-bit register that stores data for port 6 pins p6 7 to p6 0 . if port 6 is read while pcr6 bits are set to 1, the values stored in pdr6 are read, regardless of the actual pin states. if port 6 is read while pcr6 bits are cleared to 0, the pin states are read. upon reset, pdr6 is initialized to h'00. 2. port control register 6 (pcr6) bit initial value read/write 7 pcr6 7 0 w 6 pcr6 6 0 w 5 pcr6 5 0 w 4 pcr6 4 0 w 3 pcr6 3 0 w 0 pcr6 0 0 w 2 pcr6 2 0 w 1 pcr6 1 0 w pcr6 is an 8-bit register for controlling whether each of the port 6 pins p6 7 to p6 0 functions as an input pin or output pin. setting a pcr6 bit to 1 makes the corresponding pin (p6 7 to p6 0 ) an output pin, while clearing the bit to 0 makes the pin an input pin. upon reset, pcr6 is initialized to h'00. pcr6 is a write-only register, which always reads all 1s. 3. port pull-up control register 6 (pucr6) b it i nitial value r ead/write 7 pucr6 0 r/w 6 pucr6 0 r/w 5 pucr6 0 r/w 4 pucr6 0 r/w 3 pucr6 0 r/w 0 pucr6 0 r/w 2 pucr6 0 r/w 1 pucr6 0 r/w 2 10 5 43 76 pucr6 controls whether the mos pull-up of each of the port 6 pins p6 7 to p6 0 is on or off. when a pcr6 bit is cleared to 0, setting the corresponding pucr6 bit to 1 turns on the mos pull-up for the corresponding pin, while clearing the bit to 0 turns off the mos pull-up. upon reset, pucr6 is initialized to h'00.
164 8.7.3 pin functions table 8-18 shows the port 6 pin functions. table 8-18 port 6 pin functions pin pin functions and selection method p6 7 to p6 0 the pin function depends on bit pcr6 n in pcr6. (n = 7 to 0) pcr6 n 01 pin function p6 n input pin p6 n output pin 8.7.4 pin states table 8-19 shows the port 6 pin states in each operating mode. table 8-19 port 6 pin states pins reset sleep subsleep standby watch subactive active p6 7 to p6 0 high- impedance retains previous state retains previous state high- impedance * retains previous state functional functional note: * a high-level signal is output when the mos pull-up is in the on state. 8.7.5 mos input pull-up port 6 has a built-in mos pull-up function that can be controlled by software. when a pcr6 bit is cleared to 0, setting the corresponding pucr6 bit to 1 turns on the mos pull-up for that pin. the mos pull-up function is in the off state after a reset. pcr6 n 00 1 pucr6 n 01 * mos input pull-up off on off (n = 7 to 0) * : don t care
165 8.8 port 7 8.8.1 overview port 7 is an 8-bit i/o port, configured as shown in figure 8-7. p7 7 p7 6 p7 5 p7 4 p7 3 port 7 p7 2 p7 1 p7 0 figure 8-7 port 7 pin configuration 8.8.2 register configuration and description table 8-20 shows the port 7 register configuration. table 8-20 port 7 registers name abbrev. r/w initial value address port data register 7 pdr7 r/w h'00 h'ffda port control register 7 pcr7 w h'00 h'ffea
166 1. port data register 7 (pdr7) bit initial value read/write 7 p7 0 r/w 6 p7 0 r/w 5 p7 0 r/w 4 p7 0 r/w 3 p7 0 r/w 0 p7 0 r/w 2 p7 0 r/w 1 p7 0 r/w 76543210 pdr7 is an 8-bit register that stores data for port 7 pins p7 7 to p7 0 . if port 7 is read while pcr7 bits are set to 1, the values stored in pdr7 are read, regardless of the actual pin states. if port 7 is read while pcr7 bits are cleared to 0, the pin states are read. upon reset, pdr7 is initialized to h'00. 2. port control register 7 (pcr7) bit initial value read/write 7 pcr7 0 w 6 pcr7 0 w 5 pcr7 0 w 4 pcr7 0 w 3 pcr7 0 w 0 pcr7 0 w 2 pcr7 0 w 1 pcr7 0 w 76543210 pcr7 is an 8-bit register for controlling whether each of the port 7 pins p7 7 to p7 0 functions as an input pin or output pin. setting a pcr7 bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. upon reset, pcr7 is initialized to h'00. pcr7 is a write-only register, which always reads as all 1s.
167 8.8.3 pin functions table 8-21 shows the port 7 pin functions. table 8-21 port 7 pin functions pin pin functions and selection method p7 7 to p7 0 the pin function depends on bit pcr7 n in pcr7. (n = 7 to 0) pcr7 n 01 pin function p7 n input pin p7 n output pin 8.8.4 pin states table 8-22 shows the port 7 pin states in each operating mode. table 8-22 port 7 pin states pins reset sleep subsleep standby watch subactive active p7 7 to p7 0 high- impedance retains previous state retains previous state high- impedance retains previous state functional functional
168 8.9 port 8 8.9.1 overview port 8 is an 8-bit i/o port configured as shown in figure 8-8. p8 7 p8 6 p8 5 p8 4 p8 3 port 8 p8 2 p8 1 p8 0 figure 8-8 port 8 pin configuration 8.9.2 register configuration and description table 8-23 shows the port 8 register configuration. table 8-23 port 8 registers name abbrev. r/w initial value address port data register 8 pdr8 r/w h'00 h'ffdb port control register 8 pcr8 w h'00 h'ffeb 1. port data register 8 (pdr8) bit initial value read/write 7 p8 0 r/w 6 p8 0 r/w 5 p8 0 r/w 4 p8 0 r/w 3 p8 0 r/w 0 p8 0 r/w 2 p8 0 r/w 1 p8 0 r/w 76543210 pdr8 is an 8-bit register that stores data for port 8 pins p8 7 to p8 0 . if port 8 is read while pcr8 bits are set to 1, the values stored in pdr8 are read, regardless of the actual pin states. if port 8 is read while pcr8 bits are cleared to 0, the pin states are read. upon reset, pdr8 is initialized to h'00.
169 2. port control register 8 (pcr8) b it i nitial value r ead/write 7 pcr8 0 w 6 pcr8 0 w 5 pcr8 0 w 4 pcr8 0 w 3 pcr8 0 w 0 pcr8 0 w 2 pcr8 0 w 1 pcr8 0 w 76543210 pcr8 is an 8-bit register for controlling whether each of the port 8 pins p8 7 to p8 0 functions as an input or output pin. setting a pcr8 bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. upon reset, pcr8 is initialized to h'00. pcr8 is a write-only register, which is always read as all 1s. 8.9.3 pin functions table 8-24 shows the port 8 pin functions. table 8-24 port 8 pin functions pin pin functions and selection method p8 7 to p8 0 the pin function depends on bit pcr8 n in pcr8. (n = 7 to 0) pcr8 n 01 pin function p8 n input pin p8 n output pin 8.9.4 pin states table 8-25 shows the port 8 pin states in each operating mode. table 8-25 port 8 pin states pins reset sleep subsleep standby watch subactive active p8 7 to p8 0 high- impedance retains previous state retains previous state high- impedance retains previous state functional functional
170 8.10 port 9 8.10.1 overview port 9 is a 4-bit i/o port. figure 8-9 shows its pin configuration. p9 3 p9 2 p9 1 p9 0 port 9 figure 8-9 port 9 pin configuration 8.10.2 register configuration and description table 8-26 shows the port 9 register configuration. table 8-26 port 9 registers name abbrev. r/w initial value address port data register 9 pdr9 r/w h'00 h'ffdc port control register 9 pcr9 r h'f0 h'ffec
171 1. port data register 9 (pdr9) b it i nitial value r ead/write 7 0 6 0 5 0 4 0 3 p9 3 0 r/w 0 p9 0 0 r/w 2 p9 2 0 r/w 1 p9 1 0 r/w pdr9 is an 8-bit register that stores data for port 9 pins p9 3 to p9 0 . if port 9 is read while pcr9 bits are set to 1, the values stored in pdr9 are read, regardless of the actual pin states. if port 9 is read while pcr9 bits are cleared to 0, the pin states are read. upon reset, pdr9 is initialized to h'f0. 2. port control register 9 (pcr9) b it i nitial value r ead/write 7 1 6 1 5 1 4 1 3 pcr9 3 0 w 0 pcr9 0 0 w 2 pcr9 2 0 w 1 pcr9 1 0 w pcr9 is an 8-bit register for controlling whether each of the port 9 pins p9 3 to p9 0 functions as an input pin or output pin. setting a pcr9 bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. upon reset, pcr9 is initialized to h'f0. pcr9 is a write-only register, which is always read as all 1s.
172 8.10.3 pin functions table 8-27 shows the port 9 pin functions. table 8-27 port 9 pin functions pin pin functions and selection method p9 3 to p9 0 the pin function depends on bit pcr9 n in pcr9. (n = 3 to 0) pcr9 n 01 pin function p9 n input pin p9 n output pin 8.10.4 pin states table 8-28 shows the port 9 pin states in each operating mode. table 8-28 port 9 pin states pins reset sleep subsleep standby watch subactive active p9 3 to p9 0 high- impedance retains previous state retains previous state high- impedance retains previous state functional functional
173 8.11 port a 8.11.1 overview port a is a 4-bit i/o port, configured as shown in figure 8-10. pa 3 pa 2 pa 1 pa 0 port a figure 8-10 port a pin configuration 8.11.2 register configuration and description table 8-29 shows the port a register configuration. table 8-29 port a registers name abbrev. r/w initial value address port data register a pdra r/w h'f0 h'ffdd port control register a pcra w h'f0 h'ffed 1. port data register a (pdra) b it i nitial value r ead/write 7 1 6 1 5 1 4 1 3 pa 0 r/w 0 pa 0 r/w 2 pa 0 r/w 1 pa 0 r/w 3210 pdra is an 8-bit register that stores data for port a pins pa 3 to pa 0 . if port a is read while pcra bits are set to 1, the values stored in pdra are read, regardless of the actual pin states. if port a is read while pcra bits are cleared to 0, the pin states are read. upon reset, pdra is initialized to h'f0.
174 2. port control register a (pcra) bit initial value read/write 7 1 6 1 5 1 4 1 3 pcra 0 r/w 0 pcra 0 r/w 2 pcra 0 r/w 1 pcra 0 r/w 3210 pcra controls whether each of port a pins pa 3 to pa 0 functions as an input pin or output pin. setting a pcra bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. upon reset, pcra is initialized to h'f0. pcra is a write-only register, which always reads all 1s. 8.11.3 pin functions table 8-30 shows the port a pin functions. table 8-30 port a pin functions pin pin functions and selection method pa 3 to pa 0 the pin function depends on bit pcra n in pcra. (n = 3 to 0) pcra n 01 pin function pa n input pin pa n output pin 8.11.4 pin states table 8-31 shows the port a pin states in each operating mode. table 8-31 port a pin states pins reset sleep subsleep standby watch subactive active pa 3 to pa 0 high- impedance retains previous state retains previous state high- impedance retains previous state functional functional
175 8.12 port b 8.12.1 overview port b is an 8-bit input-only port, configured as shown in figure 8-11. pb 7 /an 7 pb 6 /an 6 pb 5 /an 5 pb 4 /an 4 pb 3 /an 3 port b pb 2 /an 2 pb 1 /an 1 pb 0 /an 0 figure 8-11 port b pin configuration 8.12.2 register configuration and description table 8-32 shows the port b register configuration. table 8-32 port b register name abbrev. r/w address port data register b pdrb r h'ffde port data register b (pdrb) b it r ead/write 7 pb r 6 pb r 5 pb r 4 pb r 3 pb r 0 pb r 2 pb r 1 pb r 32 1 0 7654 reading pdrb always gives the pin states. however, if a port b pin is selected as an analog input channel for the a/d converter by amr bits ch3 to ch0, that pin reads 0 regardless of the input voltage.
176 8.13 input/output data inversion function 8.13.1 overview with input pins rxd 31 , and rxd 32 , and output pins txd 31 and txd 32 , the data can be handled in inverted form. scinv0 scinv2 rxd 31 rxd 32 p3 4 /rxd 31 p4 1 /rxd 32 scinv1 scinv3 txd 31 txd 32 p3 5 /txd 31 p4 2 /txd 32 figure 8.12 input/output data inversion function 8.13.2 register configuration and descriptions table 8.33 shows the registers used by the input/output data inversion function. table 8.33 register configuration name abbreviation r/w initial value address serial port control register spcr r/w h'c0 h'ff91 serial port control register (spcr) b it i nitial value r ead/write 7 1 6 1 5 spc32 0 r/w 4 spc31 0 r/w 3 scinv3 0 r/w 0 scinv0 0 r/w 2 scinv2 0 r/w 1 scinv1 0 r/w spcr is an 8-bit readable/writable register that performs rxd 31 , rxd 32 , txd 31 , and txd 32 pin input/output data inversion switching. spcr is initialized to h'c0 by a reset.
177 bits 7 and 6: reserved bits bits 7 and 6 are reserved; they are always read as 1 and cannot be modified. bit 5: p4 2 /txd 32 pin function switch (spc32) this bit selects whether pin p4 2 /txd 32 is used as p4 2 or as txd 32 . bit 5 spc32 description 0 functions as p4 2 i/o pin (initial value) 1 functions as txd 32 output pin * note: * set the te bit in scr3 after setting this bit to 1. bit 4: p3 5/ txd 31 pin function switch (spc31) this bit selects whether pin p3 5 /txd 31 is used as p3 5 or as txd 31 . bit 4 spc31 description 0 functions as p3 5 i/o pin (initial value) 1 functions as txd 31 output pin * note: * set the te bit in scr3 after setting this bit to 1. bit 3: txd 32 pin output data inversion switch bit 3 specifies whether or not txd 32 pin output data is to be inverted. bit 3 scinv3 description 0 txd 32 output data is not inverted (initial value) 1 txd 32 output data is inverted bit 2: rxd 32 pin input data inversion switch bit 2 specifies whether or not rxd 32 pin input data is to be inverted. bit 2 scinv2 description 0 rxd 32 input data is not inverted (initial value) 1 rxd 32 input data is inverted
178 bit 1: txd 31 pin output data inversion switch bit 1 specifies whether or not txd 31 pin output data is to be inverted. bit 1 scinv1 description 0 txd 31 output data is not inverted (initial value) 1 txd 31 output data is inverted bit 0: rxd 31 pin input data inversion switch bit 0 specifies whether or not rxd 31 pin input data is to be inverted. bit 0 scinv0 description 0 rxd 31 input data is not inverted (initial value) 1 rxd 31 input data is inverted 8.13.3 note on modification of serial port control register when a serial port control register is modified, the data being input or output up to that point is inverted immediately after the modification, and an invalid data change is input or output. when modifying a serial port control register, do so in a state in which data changes are invalidated 8.14 application note 8.14.1 the management of the un-use terminal if an i/o pin not used by the user system is floating, pull it up or down. ? if an unused pin is an input pin, handle it in one of the following ways: ? pull it up to v cc with an on-chip pull-up mos. ? pull it up to v cc with an external resister of approximately 100 k ? . ? pull it down to v ss with an external resister of approximately 100 k ? . ? if an unused pin is an output pin, handle it in one of the following ways: ? set the output of the unused pin to high and pull it up to v cc with an on-chip pull-up mos. ? set the output of the unused pin to high and pull it up to v cc with an external resister of approximately 100 k ? . ? set the output of the unused pin to low and pull it down to v ss with an external resister of approximately 100 k ? .
179 section 9 timers 9.1 overview the h8/3937 series and h8/3937r series provide five timers: timers a, c, f, g, and a watchdog timer. the functions of these timers are outlined in table 9-1. table 9-1 timer functions name functions internal clock event input pin waveform output pin remarks timer a ? 8-bit interval timer ?8 to ?8192 ? interval function (8 choices) ? time base w /128 (choice of 4 overflow periods) ? clock output ?4 to ?32 w , w /4 to w /32 (9 choices) tmow timer c ? 8-bit timer ? interval function ? event counting function ? up-count/down-count selectable ?4 to ?8192, w /4 (7 choices) tmic up- count/ down-count controllable by software or hardware timer f ? 16-bit timer ? event counting function ? also usable as two independent 8-bit timers ? output compare output function ?4 to ?32, w /4 (4 choices) tmif tmofl tmofh timer g ? 8-bit timer ? input capture function ? interval function ?2 to ?64, w /4 (4 choices) tmig counter clearing option built-in capture input signal noise canceler watchdog timer ? reset signal generated when 8-bit counter overflows ?8192 ?/32
180 9.2 timer a 9.2.1 overview timer a is an 8-bit timer with interval timing and time-base functions. a clock signal divided from 76.8 khz (if a 76.8 khz crystal oscillator is connected), from 160 khz (if a 160 khz crystal oscillator is connected), or from the system clock, can be output at the tmow pin. 1. features features of timer a are given below. ? choice of eight internal clock sources (?8192, ?4096, ?2048, ?512, ?256, ?128, ?32, ?8). ? choice of four overflow periods ( w /32768, w /16384, w /8192, w /1024) when timer a is used as a time base. ? an interrupt is requested when the counter overflows. ? any of nine clock signals can be output at the tmow pin: w divided by 32, 16, 8, or 4 and the system clock divided by 32, 16, 8, or 4. ? use of module standby mode enables this module to be placed in standby mode independently when not used.
181 2. block diagram figure 9-1 shows a block diagram of timer a. psw internal data bus pss notation: tmow 1/4 tma cwors tca w /32 w /16 w /8 w /4 /32 /16 /8 /4 /128 w /8192, /4096, /2048, /512, /256, /128, /32, /8 irrta /4 w tma: tca: irrta: psw: pss: cwosr: note: * can be selected only when the prescaler w output ( w /128) is used as the tca input clock. timer mode register a timer counter a timer a overflow interrupt request flag prescaler w prescaler s subclock output select register w figure 9-1 block diagram of timer a 3. pin configuration table 9-2 shows the timer a pin configuration. table 9-2 pin configuration name abbrev. i/o function clock output tmow output output of waveform generated by timer a output circuit
182 4. register configuration table 9-3 shows the register configuration of timer a. table 9-3 timer a registers name abbrev. r/w initial value address timer mode register a tma r/w h'10 h'ffb0 timer counter a tca r h'00 h'ffb1 clock stop register 1 ckstpr1 r/w h'ff h'fffa subclock output select register cwosr r/w h'fe h'ff92 9.2.2 register descriptions 1. timer mode register a (tma) bit initial value read/write 7 tma7 0 r/w 6 tma6 0 r/w 5 tma5 0 r/w 4 1 3 tma3 0 r/w 0 tma0 0 r/w 2 tma2 0 r/w 1 tma1 0 r/w tma is an 8-bit read/write register for selecting the prescaler, input clock, and output clock. upon reset, tma is initialized to h'10.
183 bits 7 to 5: clock output select (tma7 to tma5) bits 7 to 5 choose which of eight clock signals is output at the tmow pin. the system clock divided by 32, 16, 8, or 4 can be output in active mode and sleep mode. a w signal divided by 32, 16, 8, or 4 can be output in active mode, sleep mode, and subactive mode. w is output in all modes except the reset state. cwosr tma cwos bit 7 tma7 bit 6 tma6 bit 5 tma5 clock output 0000 /32 (initial value) 1 /16 10 /8 1 /4 100 w /32 1 w /16 10 w /8 1 w /4 1 *** w * : don t care bit 4: reserved bit bit 4 is reserved; it is always read as 1, and cannot be modified.
184 bits 3 to 0: internal clock select (tma3 to tma0) bits 3 to 0 select the clock input to tca. the selection is made as follows. description bit 3 tma3 bit 2 tma2 bit 1 tma1 bit 0 tma0 prescaler and divider ratio or overflow period function 0 0 0 0 pss, /8192 (initial value) interval timer 1 pss, /4096 1 0 pss, /2048 1 pss, /512 1 0 0 pss, /256 1 pss, /128 1 0 pss, /32 1 pss, /8 1 0 0 0 psw, w /32768 time base 1 psw, w /16384 (overflow period) 1 0 psw, w /8192 1 psw, w /1024 1 0 0 psw and tca are reset 1 10 1
185 2. timer counter a (tca) bit initial value read/write 7 tca7 0 r 6 tca6 0 r 5 tca5 0 r 4 tca4 0 r 3 tca3 0 r 0 tca0 0 r 2 tca2 0 r 1 tca1 0 r tca is an 8-bit read-only up-counter, which is incremented by internal clock input. the clock source for input to this counter is selected by bits tma3 to tma0 in timer mode register a (tma). tca values can be read by the cpu in active mode, but cannot be read in subactive mode. when tca overflows, the irrta bit in interrupt request register 1 (irr1) is set to 1. tca is cleared by setting bits tma3 and tma2 of tma to 11. upon reset, tca is initialized to h'00. 3. clock stop register 1 (ckstpr1) bit 7654 3210 s1ckstp s31ckstp s32ckstp adckstp tgckstp tfckstp tcckstp tackstp initial value 1111 1111 read/write r/w r/w r/w r/w r/w r/w r/w r/w ckstpr1 is an 8-bit read/write register that performs module standby mode control for peripheral modules. only the bit relating to timer a is described here. for details of the other bits, see the sections on the relevant modules. bit 0: timer a module standby mode control (tackstp) bit 0 controls setting and clearing of module standby mode for timer a. tackstp description 0 timer a is set to module standby mode 1 timer a module standby mode is cleared (initial value)
186 4. subclock output select register (cwosr) cwos 76543210 1 1111110 r/w bit: initial value: read/write: cwosr is an 8-bit read/write register that selects the clock to be output from the tmow pin. cwosr is initialized to h'fe by a reset. bits 7 to 1: reserved bits bits 7 to 1 are reserved; they are always read as 1 and cannot be modified. bit 0: tmow pin clock select (cwos) bit 0 selects the clock to be output from the tmow pin. bit 0 cwos description 0 clock output from timer a is output (see tma) (initial value) 1 w is output 9.2.3 timer operation 1. interval timer operation when bit tma3 in timer mode register a (tma) is cleared to 0, timer a functions as an 8-bit interval timer. upon reset, tca is cleared to h'00 and bit tma3 is cleared to 0, so up-counting and interval timing resume immediately. the clock input to timer a is selected by bits tma2 to tma0 in tma; any of eight internal clock signals output by prescaler s can be selected. after the count value in tca reaches h'ff, the next clock signal input causes timer a to overflow, setting bit irrta to 1 in interrupt request register 1 (irr1). if ienta = 1 in interrupt enable register 1 (ienr1), a cpu interrupt is requested.* at overflow, tca returns to h'00 and starts counting up again. in this mode timer a functions as an interval timer that generates an overflow output at intervals of 256 input clock pulses. note: * for details on interrupts, see 3.3, interrupts.
187 2. time base operation when bit tma3 in tma is set to 1, timer a functions as a time base by counting clock signals output by prescaler w. the overflow period of timer a is set by bits tma1 and tma0 in tma. a choice of four periods is available. in time base operation (tma3 = 1), setting bit tma2 to 1 clears both tca and prescaler w to their initial values of h'00. 3. clock output setting bit tmow in port mode register 1 (pmr1) to 1 causes a clock signal to be output at pin tmow. nine different clock output signals can be selected by means of bits tma7 to tma5 in tma and bit cwos in cwosr. the system clock divided by 32, 16, 8, or 4 can be output in active mode and sleep mode. a w signal divided by 32, 16, 8, or 4 can be output in active mode, sleep mode, watch mode, subactive mode, and subsleep mode. the w clock is output in all modes except the reset state. 9.2.4 timer a operation states table 9-4 summarizes the timer a operation states. table 9-4 timer a operation states operation mode reset active sleep watch sub- active sub- sleep standby module standby tca interval reset functions functions halted halted halted halted halted time base reset functions functions functions functions functions halted halted tma reset functions retained retained functions retained retained retained note: when the time base function is selected as the internal clock of tca in active mode or sleep mode, the internal clock is not synchronous with the system clock, so it is synchronized by a synchronizing circuit. this may result in a maximum error of 1/ (s) in the count cycle. 9.2.5 application note when bit 0 (tackstp) of the clock stop register 1 (ckstpr1) is cleared to 0, bit 3 (tma3) of the timer mode register a (tma) cannot be rewritten. set bit 0 (tackstp) of the clock stop register 1 (ckstpr1) to 1 before rewriting bit 3 (tma3) of the timer mode register a (tma).
188 9.3 timer c 9.3.1 overview timer c is an 8-bit timer that increments each time a clock pulse is input. this timer has two operation modes, interval and auto reload. 1. features features of timer c are given below. ? /8192, /2048, /512, /64, /16, /4, w /4) or an external clock (can be used to count external events). ? ? ? w /4 is selected as the internal clock, or when an external clock is selected. ?
189 2. block diagram figure 9-2 shows a block diagram of timer c. ud tmic w /4 pss tmc internal data bus tcc tlc irrtc notation: tmc tcc tlc irrtc pss : timer mode register c : timer counter c : timer load register c : timer c overflow interrupt request flag : prescaler s figure 9-2 block diagram of timer c 3. pin configuration table 9-5 shows the timer c pin configuration. table 9-5 pin configuration name abbrev. i/o function timer c event input tmic input input pin for event input to tcc timer c up/down-count selection ud input timer c up/down select
190 4. register configuration table 9-6 shows the register configuration of timer c. table 9-6 timer c registers name abbrev. r/w initial value address timer mode register c tmc r/w h'18 h'ffb4 timer counter c tcc r h'00 h'ffb5 timer load register c tlc w h'00 h'ffb5 clock stop register 1 ckstpr1 r/w h'ff h'fffa 9.3.2 register descriptions 1. timer mode register c (tmc) bit initial value read/write 7 tmc7 0 r/w 6 tmc6 0 r/w 5 tmc5 0 r/w 4 1 3 1 0 tmc0 0 r/w 2 tmc2 0 r/w 1 tmc1 0 r/w tmc is an 8-bit read/write register for selecting the auto-reload function and input clock, and performing up/down-counter control. upon reset, tmc is initialized to h'18. bit 7: auto-reload function select (tmc7) bit 7 selects whether timer c is used as an interval timer or auto-reload timer. bit 7 tmc7 description 0 interval timer function selected (initial value) 1 auto-reload function selected
191 bits 6 and 5: counter up/down control (tmc6, tmc5) selects whether tcc up/down control is performed by hardware using ud pin input, or whether tcc functions as an up-counter or a down-counter. bit 6 tmc6 bit 5 tmc5 description 0 0 tcc is an up-counter (initial value) 0 1 tcc is a down-counter 1 * hardware control by ud pin input ud pin input high: down-counter ud pin input low: up-counter * : don't care bits 4 and 3: reserved bits bits 4 and 3 are reserved; they are always read as 1 and cannot be modified. bits 2 to 0: clock select (tmc2 to tmc0) bits 2 to 0 select the clock input to tcc. for external event counting, either the rising or falling edge can be selected. bit 2 tmc2 bit 1 tmc1 bit 0 tmc0 description 0 0 0 internal clock: /8192 (initial value) 0 0 1 internal clock: /2048 0 1 0 internal clock: /512 0 1 1 internal clock: /64 1 0 0 internal clock: /16 1 0 1 internal clock: /4 1 1 0 internal clock: w /4 1 1 1 external event (tmic): rising or falling edge * note: * the edge of the external event signal is selected by bit ieg1 in the irq edge select register (iegr). see 1. irq edge select register (iegr) in 3.3.2 for details. irq2 must be set to 1 in port mode register 1 (pmr1) before setting 111 in bits tmc2 to tmc0.
192 2. timer counter c (tcc) bit initial value read/write 7 tcc7 0 r 6 tcc6 0 r 5 tcc5 0 r 4 tcc4 0 r 3 tcc3 0 r 0 tcc0 0 r 2 tcc2 0 r 1 tcc1 0 r tcc is an 8-bit read-only up-counter, which is incremented by internal clock or external event input. the clock source for input to this counter is selected by bits tmc2 to tmc0 in timer mode register c (tmc). tcc values can be read by the cpu at any time. when tcc overflows from h'ff to h'00 or to the value set in tlc, or underflows from h'00 to h'ff or to the value set in tlc, the irrtc bit in irr2 is set to 1. tcc is allocated to the same address as tlc. upon reset, tcc is initialized to h'00. 3. timer load register c (tlc) bit initial value read/write 7 tlc7 0 w 6 tlc6 0 w 5 tlc5 0 w 4 tlc4 0 w 3 tlc3 0 w 0 tlc0 0 w 2 tlc2 0 w 1 tlc1 0 w tlc is an 8-bit write-only register for setting the reload value of timer counter c (tcc). when a reload value is set in tlc, the same value is loaded into timer counter c as well, and tcc starts counting up from that value. when tcc overflows or underflows during operation in auto- reload mode, the tlc value is loaded into tcc. accordingly, overflow/underflow periods can be set within the range of 1 to 256 input clocks. the same address is allocated to tlc as to tcc. upon reset, tlc is initialized to h'00. 4. clock stop register 1 (ckstpr1) bit 7654 3210 s1ckstp s31ckstp s32ckstp adckstp tgckstp tfckstp tcckstp tackstp initial value 1111 1111 read/write r/w r/w r/w r/w r/w r/w r/w r/w
193 ckstpr1 is an 8-bit read/write register that performs module standby mode control for peripheral modules. only the bit relating to timer c is described here. for details of the other bits, see the sections on the relevant modules. bit 1: timer c module standby mode control (tcckstp) bit 1 controls setting and clearing of module standby mode for timer c. tcckstp description 0 timer c is set to module standby mode 1 timer c module standby mode is cleared (initial value) 9.3.3 timer operation 1. interval timer operation when bit tmc7 in timer mode register c (tmc) is cleared to 0, timer c functions as an 8-bit interval timer. upon reset, tcc is initialized to h'00 and tmc to h'18, so tcc continues up-counting as an interval up-counter without halting immediately after a reset. the timer c operating clock is selected from seven internal clock signals output by prescalers s and w, or an external clock input at pin tmic. the selection is made by bits tmc2 to tmc0 in tmc. tcc up/down-count control can be performed either by software or hardware. the selection is made by bits tmc6 and tmc5 in tmc. after the count value in tcc reaches h'ff (h'00), the next clock input causes timer c to overflow (underflow), setting bit irrtc to 1 in irr2. if ientc = 1 in interrupt enable register 2 (ienr2), a cpu interrupt is requested. at overflow (underflow), tcc returns to h'00 (h'ff) and starts counting up (down) again. during interval timer operation (tmc7 = 0), when a value is set in timer load register c (tlc), the same value is set in tcc. note: * for details on interrupts, see 3.3, interrupts.
194 2. auto-reload timer operation setting bit tmc7 in tmc to 1 causes timer c to function as an 8-bit auto-reload timer. when a reload value is set in tlc, the same value is loaded into tcc, becoming the value from which tcc starts its count. after the count value in tcc reaches h'ff (h'00), the next clock signal input causes timer c to overflow/underflow. the tlc value is then loaded into tcc, and the count continues from that value. the overflow/underflow period can be set within a range from 1 to 256 input clocks, depending on the tlc value. the clock sources, up/down control, and interrupts in auto-reload mode are the same as in interval mode. in auto-reload mode (tmc7 = 1), when a new value is set in tlc, the tlc value is also set in tcc. 3. event counter operation timer c can operate as an event counter, counting rising or falling edges of an external event signal input at pin tmic. external event counting is selected by setting bits tmc2 to tmc0 in timer mode register c to all 1s (111). when timer c is used to count external event input, , bit irq2 in pmr1 should be set to 1 and bit ien2 in ienr1 cleared to 0 to disable interrupt irq2 requests. 4. tcc up/down control by hardware with timer c, tcc up/down control can be performed by ud pin input. when bit tmc6 is set to 1 in tmc, tcc functions as an up-counter when ud pin input is high, and as a down-counter when low. when using ud pin input, set bit ud to 1 in pmr3.
195 9.3.4 timer c operation states table 9-7 summarizes the timer c operation states. table 9-7 timer c operation states operation mode reset active sleep watch sub- active sub- sleep standby module standby tcc interval reset functions functions halted functions/ halted * functions/ halted * halted halted auto reload reset functions functions halted functions/ halted * functions/ halted * halted halted tmc reset functions retained retained functions retained retained retained note: * when w/4 is selected as the tcc internal clock in active mode or sleep mode, since the system clock and internal clock are mutually asynchronous, synchronization is maintained by a synchronization circuit. this results in a maximum count cycle error of 1/ (s). when the counter is operated in subactive mode or subsleep mode, either select w/4 as the internal clock or select an external clock. the counter will not operate on any other internal clock. if w/4 is selected as the internal clock for the counter when w/8 has been selected as subclock sub , the lower 2 bits of the counter operate on the same cycle, and the operation of the least significant bit is unrelated to the operation of the counter.
196 9.4 timer f 9.4.1 overview timer f is a 16-bit timer with a built-in output compare function. as well as counting external events, timer f also provides for counter resetting, interrupt request generation, toggle output, etc., using compare match signals. timer f can also be used as two independent 8-bit timers (timer fh and timer fl). 1. features features of timer f are given below. ? /32, /16, /4, w/4) or an external clock (can be used as an external event counter) ? ? ? ? timer fh 8-bit timer * timer fl 8-bit timer/event counter internal clock choice of 4 ( /32, /16, /4, w/4) event input tmif pin toggle output one compare match signal, output to tmofh pin (initial value settable) one compare match signal, output to tmofl pin (initial value settable) counter reset counter can be reset by compare match signal interrupt sources one compare match one overflow note: * when timer f operates as a 16-bit timer, it operates on the timer fl overflow signal. ? w/4 is selected as the internal clock, timer f can operate in watch mode, subactive mode, and subsleep mode. ?
197 2. block diagram figure 9-3 shows a block diagram of timer f. pss toggle circuit tcrf tcfl comparator ocrfl match tcfh comparator ocrfh tcsrf w/4 tmif tmofl tmofh legend irrtfh irrtfl tcrf tcsrf tcfh tcfl ocrfh ocrfl irrtfh irrtfl pss : timer control register f : timer control status register f : 8-bit timer counter fh : 8-bit timer counter fl : output compare register fh : output compare register fl : timer fh interrupt request flag : timer fl interrupt request flag : prescaler s internal data bus toggle circuit figure 9-3 block diagram of timer f
198 3. pin configuration table 9-8 shows the timer f pin configuration. table 9-8 pin configuration name abbrev. i/o function timer f event input tmif input event input pin for input to tcfl timer fh output tmofh output timer fh toggle output pin timer fl output tmofl output timer fl toggle output pin 4. register configuration table 9-9 shows the register configuration of timer f. table 9-9 timer f registers name abbrev. r/w initial value address timer control register f tcrf w h'00 h'ffb6 timer control/status register f tcsrf r/w h'00 h'ffb7 8-bit timer counter fh tcfh r/w h'00 h'ffb8 8-bit timer counter fl tcfl r/w h'00 h'ffb9 output compare register fh ocrfh r/w h'ff h'ffba output compare register fl ocrfl r/w h'ff h'ffbb clock stop register 1 ckstpr1 r/w h'ff h'fffa
199 9.4.2 register descriptions 1. 16-bit timer counter (tcf) 8-bit timer counter (tcfh) 8-bit timer counter (tcfl) 15 14 13 12 11 10 9 8 tcf tcfh tcfl 76543210 0000000000000000 r/w bit: initial value: read/write: r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w tcf is a 16-bit read/write up-counter configured by cascaded connection of 8-bit timer counters tcfh and tcfl. in addition to the use of tcf as a 16-bit counter with tcfh as the upper 8 bits and tcfl as the lower 8 bits, tcfh and tcfl can also be used as independent 8-bit counters. tcfh and tcfl can be read and written by the cpu, but when they are used in 16-bit mode, data transfer to and from the cpu is performed via a temporary register (temp). for details of temp, see 9.4.3, cpu interface. tcfh and tcfl are each initialized to h'00 upon reset. a. 16-bit mode (tcf) when cksh2 is cleared to 0 in tcrf, tcf operates as a 16-bit counter. the tcf input clock is selected by bits cksl2 to cksl0 in tcrf. tcf can be cleared in the event of a compare match by means of cclrh in tcsrf. when tcf overflows from h'ffff to h'0000, ovfh is set to 1 in tcsrf. if ovieh in tcsrf is 1 at this time, irrtfh is set to 1 in irr2, and if ientfh in ienr2 is 1, an interrupt request is sent to the cpu. b. 8-bit mode (tcfl/tcfh) when cksh2 is set to 1 in tcrf, tcfh and tcfl operate as two independent 8-bit counters. the tcfh (tcfl) input clock is selected by bits cksh2 to cksh0 (cksl2 to cksl0) in tcrf. tcfh (tcfl) can be cleared in the event of a compare match by means of cclrh (cclrl) in tcsrf. when tcfh (tcfl) overflows from h'ff to h'00, ovfh (ovfl) is set to 1 in tcsrf. if ovieh (oviel) in tcsrf is 1 at this time, irrtfh (irrtfl) is set to 1 in irr2, and if ientfh (ientfl) in ienr2 is 1, an interrupt request is sent to the cpu.
200 2. 16-bit output compare register (ocrf) 8-bit output compare register (ocrfh) 8-bit output compare register (ocrfl) 15 14 13 12 11 10 9 8 ocrf ocrfh ocrfl 76543210 1111111111111111 r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w r/w bit: initial value: read/write: ocrf is a 16-bit read/write register composed of the two registers ocrfh and ocrfl. in addition to the use of ocrf as a 16-bit register with ocrfh as the upper 8 bits and ocrfl as the lower 8 bits, ocrfh and ocrfl can also be used as independent 8-bit registers. ocrfh and ocrfl can be read and written by the cpu, but when they are used in 16-bit mode, data transfer to and from the cpu is performed via a temporary register (temp). for details of temp, see 9.4.3, cpu interface. ocrfh and ocrfl are each initialized to h'ff upon reset. a. 16-bit mode (ocrf) when cksh2 is cleared to 0 in tcrf, ocrf operates as a 16-bit register. ocrf contents are constantly compared with tcf, and when both values match, cmfh is set to 1 in tcsrf. at the same time, irrtfh is set to 1 in irr2. if ientfh in ienr2 is 1 at this time, an interrupt request is sent to the cpu. toggle output can be provided from the tmofh pin by means of compare matches, and the output level can be set (high or low) by means of tolh in tcrf. b. 8-bit mode (ocrfh/ocrfl) when cksh2 is set to 1 in tcrf, ocrfh and ocrfl operate as two independent 8-bit registers. ocrfh contents are compared with tcfh, and ocrfl contents are with tcfl. when the ocrfh (ocrfl) and tcfh (tcfl) values match, cmfh (cmfl) is set to 1 in tcsrf. at the same time, irrtfh (irrtfl) is set to 1 in irr2. if ientfh (ientfl) in ienr2 is 1 at this time, an interrupt request is sent to the cpu. toggle output can be provided from the tmofh pin (tmofl pin) by means of compare matches, and the output level can be set (high or low) by means of tolh (toll) in tcrf.
201 3. timer control register f (tcrf) tolh cksl2 cksl1 cksl0 cksh2 cksh1 cksh0 toll 76543210 0 0000000 w www www w bit: initial value: read/write: tcrf is an 8-bit write-only register that switches between 16-bit mode and 8-bit mode, selects the input clock from among four internal clock sources or external event input, and sets the output level of the tmofh and tmofl pins. tcrf is initialized to h'00 upon reset. bit 7: toggle output level h (tolh) bit 7 sets the tmofh pin output level. the output level is effective immediately after this bit is written. bit 7 tolh description 0 low level (initial value) 1 high level bits 6 to 4: clock select h (cksh2 to cksh0) bits 6 to 4 select the clock input to tcfh from among four internal clock sources or tcfl overflow. bit 6 cksh2 bit 5 cksh1 bit 4 cksh0 description 0 0 0 16-bit mode, counting on tcfl overflow signal (initial value) 001 010 0 1 1 not available 1 0 0 internal clock: counting on /32 1 0 1 internal clock: counting on /16 1 1 0 internal clock: counting on /4 1 1 1 internal clock: counting on w/4 * : don't care
202 bit 3: toggle output level l (toll) bit 3 sets the tmofl pin output level. the output level is effective immediately after this bit is written. bit 3 toll description 0 low level (initial value) 1 high level bits 2 to 0: clock select l (cksl2 to cksl0) bits 2 to 0 select the clock input to tcfl from among four internal clock sources or external event input. bit 2 cksl2 bit 1 cksl1 bit 0 cksl0 description 0 0 0 counting on external event (tmif) rising/falling (initial value) 0 0 1 edge * 1 010 0 1 1 not available 1 0 0 internal clock: counting on /32 1 0 1 internal clock: counting on /16 1 1 0 internal clock: counting on /4 1 1 1 internal clock: counting on w/4 * : don't care note: 1. external event edge selection is set by ieg3 in the irq edge select register (iegr). for details, see 1. irq edge select register (iegr) in section 3.3.2. note that the timer f counter may increment if the setting of irq3 in port mode register 1 (pmr1) is changed from 0 to 1 while the tmif pin is low in order to change the tmif pin function.
203 4. timer control/status register f (tcsrf) ovfh cmfl oviel cclrl cmfh ovieh cclrh ovfl 76543210 0 0000000 r/(w) * r/(w) * r/w r/w r/(w) * r/w r/w r/(w) * bit: initial value: read/write: note: * bits 7, 6, 3, and 2 can only be written with 0, for flag clearing. tcsrf is an 8-bit read/write register that performs counter clear selection, overflow flag setting, and compare match flag setting, and controls enabling of overflow interrupt requests. tcsrf is initialized to h'00 upon reset. bit 7: timer overflow flag h (ovfh) bit 7 is a status flag indicating that tcfh has overflowed from h'ff to h'00. this flag is set by hardware and cleared by software. it cannot be set by software. bit 7 ovfh description 0 clearing conditions: after reading ovfh = 1, cleared by writing 0 to ovfh (initial value) 1 setting conditions: set when tcfh overflows from h'ff to h'00 bit 6: compare match flag h (cmfh) bit 6 is a status flag indicating that tcfh has matched ocrfh. this flag is set by hardware and cleared by software. it cannot be set by software. bit 6 cmfh description 0 clearing conditions: after reading cmfh = 1, cleared by writing 0 to cmfh (initial value) 1 setting conditions: set when the tcfh value matches the ocrfh value
204 bit 5: timer overflow interrupt enable h (ovieh) bit 5 selects enabling or disabling of interrupt generation when tcfh overflows. bit 5 ovieh description 0 tcfh overflow interrupt request is disabled (initial value) 1 tcfh overflow interrupt request is enabled bit 4: counter clear h (cclrh) in 8-bit mode, bit 4 selects whether tcf is cleared when tcf and ocrf match. in 8-bit mode, bit 4 selects whether tcfh is cleared when tcfh and ocrfh match. bit 4 cclrh description 0 16-bit mode: tcf clearing by compare match is disabled 8-bit mode: tcfh clearing by compare match is disabled (initial value) 1 16-bit mode: tcf clearing by compare match is enabled 8-bit mode: tcfh clearing by compare match is enabled bit 3: timer overflow flag l (ovfl) bit 3 is a status flag indicating that tcfl has overflowed from h'ff to h'00. this flag is set by hardware and cleared by software. it cannot be set by software. bit 3 ovfl description 0 clearing conditions: after reading ovfl = 1, cleared by writing 0 to ovfl (initial value) 1 setting conditions: set when tcfl overflows from h'ff to h'00
205 bit 2: compare match flag l (cmfl) bit 2 is a status flag indicating that tcfl has matched ocrfl. this flag is set by hardware and cleared by software. it cannot be set by software. bit 2 cmfl description 0 clearing conditions: after reading cmfl = 1, cleared by writing 0 to cmfl (initial value) 1 setting conditions: set when the tcfl value matches the ocrfl value bit 1: timer overflow interrupt enable l (oviel) bit 1 selects enabling or disabling of interrupt generation when tcfl overflows. bit 1 oviel description 0 tcfl overflow interrupt request is disabled (initial value) 1 tcfl overflow interrupt request is enabled bit 0: counter clear l (cclrl) bit 0 selects whether tcfl is cleared when tcfl and ocrfl match. bit 0 cclrl description 0 tcfl clearing by compare match is disabled (initial value) 1 tcfl clearing by compare match is enabled 5. clock stop register 1 (ckstpr1) bit 7654 3210 s1ckstp s31ckstp s32ckstp adckstp tgckstp tfckstp tcckstp tackstp initial value 1111 1111 read/write r/w r/w r/w r/w r/w r/w r/w r/w ckstpr1 is an 8-bit read/write register that performs module standby mode control for peripheral modules. only the bit relating to timer f is described here. for details of the other bits, see the sections on the relevant modules.
206 bit 2: timer f module standby mode control (tfckstp) bit 2 controls setting and clearing of module standby mode for timer f. tfckstp description 0 timer f is set to module standby mode 1 timer f module standby mode is cleared (initial value) 9.4.3 cpu interface tcf and ocrf are 16-bit read/write registers, but the cpu is connected to the on-chip peripheral modules by an 8-bit data bus. when the cpu accesses these registers, it therefore uses an 8-bit temporary register (temp). in 16-bit mode, tcf read/write access and ocrf write access must be performed 16 bits at a time (using two consecutive byte-size mov instructions), and the upper byte must be accessed before the lower byte. data will not be transferred correctly if only the upper byte or only the lower byte is accessed. in 8-bit mode, there are no restrictions on the order of access.
207 1. write access write access to the upper byte results in transfer of the upper-byte write data to temp. next, write access to the lower byte results in transfer of the data in temp to the upper register byte, and direct transfer of the lower-byte write data to the lower register byte. figure 9-4 shows an example in which h'aa55 is written to tcf. write to upper byte cpu (h'aa) temp (h'aa) tcfh ( ) tcfl ( ) bus interface module data bus write to lower byte cpu (h'55) temp (h'aa) tcfh (h'aa) tcfl (h'55) bus interface module data bus figure 9-4 write access to tcf (cpu tcf)
208 2. read access in access to tcf, when the upper byte is read the upper-byte data is transferred directly to the cpu and the lower-byte data is transferred to temp. next, when the lower byte is read, the lower-byte data in temp is transferred to the cpu. in access to ocrf, when the upper byte is read the upper-byte data is transferred directly to the cpu. when the lower byte is read, the lower-byte data is transferred directly to the cpu. figure 9-5 shows an example in which tcf is read when it contains h'aaff. read upper byte cpu (h'aa) temp (h'ff) tcfh (h'aa) tcfl (h'ff) bus interface module data bus read lower byte cpu (h'ff) temp (h'ff) tcfh (ab)* tcfl (00)* bus interface module data bus note: * h'ab00 if counter has been updated once. figure 9-5 read access to tcf (tcf cpu)
209 9.4.4 operation timer f is a 16-bit counter that increments on each input clock pulse. the timer f value is constantly compared with the value set in output compare register f, and the counter can be cleared, an interrupt requested, or port output toggled, when the two values match. timer f can also function as two independent 8-bit timers. 1. timer f operation timer f has two operating modes, 16-bit timer mode and 8-bit timer mode. the operation in each of these modes is described below. a. operation in 16-bit timer mode when cksh2 is cleared to 0 in timer control register f (tcrf), timer f operates as a 16- bit timer. following a reset, timer counter f (tcf) is initialized to h'0000, output compare register f (ocrf) to h'ffff, and timer control register f (tcrf) and timer control/status register f (tcsrf) to h'00. the counter starts incrementing on external event (tmif) input. the external event edge selection is set by ieg3 in the irq edge select register (iegr). the timer f operating clock can be selected from four internal clocks output by prescaler s or an external clock by means of bits cksl2 to cksl0 in tcrf. ocrf contents are constantly compared with tcf, and when both values match, cmfh is set to 1 in tcsrf. if ientfh in ienr2 is 1 at this time, an interrupt request is sent to the cpu, and at the same time, tmofh pin output is toggled. if cclrh in tcsrf is 1, tcf is cleared. tmofh pin output can also be set by tolh in tcrf. when tcf overflows from h'ffff to h'0000, ovfh is set to 1 in tcsrf. if ovieh in tcsrf and ientfh in ienr2 are both 1, an interrupt request is sent to the cpu. b. operation in 8-bit timer mode when cksh2 is set to 1 in tcrf, tcf operates as two independent 8-bit timers, tcfh and tcfl. the tcfh/tcfl input clock is selected by cksh2 to cksh0/cksl2 to cksl0 in tcrf. when the ocrfh/ocrfl and tcfh/tcfl values match, cmfh/cmfl is set to 1 in tcsrf. if ientfh/ientfl in ienr2 is 1, an interrupt request is sent to the cpu, and at the same time, tmofh pin/tmofl pin output is toggled. if cclrh/cclrl in tcsrf is 1, tcfh/tcfl is cleared. tmofh pin/tmofl pin output can also be set by tolh/toll in tcrf. when tcfh/tcfl overflows from h'ff to h'00, ovfh/ovfl is set to 1 in tcsrf. if ovieh/oviel in tcsrf and ientfh/ientfl in ienr2 are both 1, an interrupt request is sent to the cpu.
210 2. tcf increment timing tcf is incremented by clock input (internal clock or external event input). a. internal clock operation bits cksh2 to cksh0 or cksl2 to cksl0 in tcrf select one of four internal clock sources ( /32, /16, /4, or w/4) created by dividing the system clock ( or w). b. external event operation external event input is selected by clearing cksl2 to 0 in tcrf. tcf can increment on either the rising or falling edge of external event input. external event edge selection is set by ieg3 in the interrupt controller's iegr register. an external event pulse width of at least 2 system clocks ( ) is necessary. shorter pulses will not be counted correctly. 3. tmofh/tmofl output timing in tmofh/tmofl output, the value set in tolh/toll in tcrf is output. the output is toggled by the occurrence of a compare match. figure 9-6 shows the output timing. tmif (when ieg3 = 1) count input clock tcf ocrf tmofh tmofl compare match signal nn n n n+1 n+1 figure 9-6 tmofh/tmofl output timing
211 4. tcf clear timing tcf can be cleared by a compare match with ocrf. 5. timer overflow flag (ovf) set timing ovf is set to 1 when tcf overflows from h'ffff to h'0000. 6. compare match flag set timing the compare match flag (cmfh or cmfl) is set to 1 when the tcf and ocrf values match. the compare match signal is generated in the last state during which the values match (when tcf is updated from the matching value to a new value). when tcf matches ocrf, the compare match signal is not generated until the next counter clock. 7. timer f operation modes timer f operation modes are shown in table 9-10. table 9-10 timer f operation modes operation mode reset active sleep watch subactive subsleep standby module standby tcf reset functions functions functions/ halted * functions/ halted * functions/ halted * halted halted ocrf reset functions held held functions held held held tcrf reset functions held held functions held held held tcsrf reset functions held held functions held held held note: * when w /4 is selected as the tcf internal clock in active mode or sleep mode, since the system clock and internal clock are mutually asynchronous, synchronization is maintained by a synchronization circuit. this results in a maximum count cycle error of 1/ (s). when the counter is operated in subactive mode, watch mode, or subsleep mode, w /4 must be selected as the internal clock. the counter will not operate if any other internal clock is selected.
212 9.4.5 application notes the following types of contention and operation can occur when timer f is used. 1. 16-bit timer mode in toggle output, tmofh pin output is toggled when all 16 bits match and a compare match signal is generated. if a tcrf write by a mov instruction and generation of the compare match signal occur simultaneously, tolh data is output to the tmofh pin as a result of the tcrf write. tmofl pin output is unstable in 16-bit mode, and should not be used; the tmofl pin should be used as a port pin. if an ocrfl write and compare match signal generation occur simultaneously, the compare match signal is invalid. however, if the written data and the counter value match, a compare match signal will be generated at that point. as the compare match signal is output in synchronization with the tcfl clock, a compare match will not result in compare match signal generation if the clock is stopped. compare match flag cmfh is set when all 16 bits match and a compare match signal is generated. compare match flag cmfl is set if the setting conditions for the lower 8 bits are satisfied. when tcf overflows, ovfh is set. ovfl is set if the setting conditions are satisfied when the lower 8 bits overflow. if a tcfl write and overflow signal output occur simultaneously, the overflow signal is not output. 2. 8-bit timer mode a. tcfh, ocrfh in toggle output, tmofh pin output is toggled when a compare match occurs. if a tcrf write by a mov instruction and generation of the compare match signal occur simultaneously, tolh data is output to the tmofh pin as a result of the tcrf write. if an ocrfh write and compare match signal generation occur simultaneously, the compare match signal is invalid. however, if the written data and the counter value match, a compare match signal will be generated at that point. the compare match signal is output in synchronization with the tcfh clock. if a tcfh write and overflow signal output occur simultaneously, the overflow signal is not output. b. tcfl, ocrfl in toggle output, tmofl pin output is toggled when a compare match occurs. if a tcrf write by a mov instruction and generation of the compare match signal occur simultaneously, toll data is output to the tmofl pin as a result of the tcrf write.
213 if an ocrfl write and compare match signal generation occur simultaneously, the compare match signal is invalid. however, if the written data and the counter value match, a compare match signal will be generated at that point. as the compare match signal is output in synchronization with the tcfl clock, a compare match will not result in compare match signal generation if the clock is stopped. if a tcfl write and overflow signal output occur simultaneously, the overflow signal is not output. 3. clear timer fh, timer fl interrupt request flags (irrtfh, irrtfl), timer overflow flags h, l (ovfh, ovfl) and compare match flags h, l (cmfh, cmfl) when w/4 is selected as the internal clock, interrupt factor generation signal will be operated with w and the signal will be outputted with w width. and, overflow signal and compare match signal are controlled with 2 cycles of w signals. those signals are outputted with 2 cycles width of w (figure 9-7) in active (high-speed, medium-speed) mode, even if you cleared interrupt request flag during the term of validity of interrupt factor generation signal , same interrupt request flag is set. (figure 9- 7 1) and, you cannot be cleared timer overflow flag and compare match flag during the term of validity of overflow signal and compare match signal . for interrupt request flag is set right after interrupt request is cleared, interrupt process to one time timer fh, timer fl interrupt might be repeated. (figure 9-7 2) therefore, to definitely clear interrupt request flag in active (high-speed, medium-speed) mode, clear should be processed after the time that calculated with below (1) formula. and, to definitely clear timer overflow flag and compare match flag, clear should be processed after read timer control status register f (tcsrf) after the time that calculated with below (1) formula. for st of (1) formula, please substitute the longest number of execution states in used instruction. (10 states of rte instruction when mulxu, divxu instruction is not used, 14 states when mulxu, divxu instruction is used) in subactive mode, there are not limitation for interrupt request flag, timer overflow flag, and compare match flag clear. the term of validity of interrupt factor generation signal = 1 cycle of w + waiting time for completion of executing instruction + interrupt time synchronized with = 1/ w + st ) + (2/ ) (second).....(1) st: executing number of execution states method 1 is recommended to operate for time efficiency. method 1 1. prohibit interrupt in interrupt handling routine (set ienfh, ienfl to 0). 2. after program process returned normal handling, clear interrupt request flags (irrtfh, irrtfl) after more than that calculated with (1) formula.
214 3. after read timer control status register f (tcsrf), clear timer overflow flags (ovfh, ovfl) and compare match flags (cmfh, cmfl). 4. operate interrupt permission (set ienfh, ienfl to 1). method 2 1. set interrupt handling routine time to more than time that calculated with (1) formula. 2. clear interrupt request flags (irrtfh, irrtfl) at the end of interrupt handling routine. 3. after read timer control status register f (tcsrf), clear timer overflow flags (ovfh, ovfl) and compare match flags (cmfh, cmfl). all above attentions are also applied in 16-bit mode and 8-bit mode. program process w interrupt request flag (irrtfh, irrtfl) interrupt factor generation signal (internal signal, nega-active) overflow signal, compare match signal (internal signal, nega-active) interrupt interrupt normal interrupt request flag clear interrupt request flag clear 1 2 figure 9-7 clear interrupt request flag when interrupt factor generation signal is valid 4. timer counter (tcf) read/write when w/4 is selected as the internal clock in active (high-speed, medium-speed) mode, write on tcf is impossible. and, when read tcf, as the system clock and internal clock are mutually asynchronous, tcf synchronizes with synchronization circuit. this results in a maximum tcf read value error of w/4 before read/write. in subactive mode, even w/4 is selected as the internal clock, normal read/write tcf is possible.
215 9.5 timer g 9.5.1 overview timer g is an 8-bit timer with dedicated input capture functions for the rising/falling edges of pulses input from the input capture input pin (input capture input signal). high-frequency component noise in the input capture input signal can be eliminated by a noise canceler, enabling accurate measurement of the input capture input signal duty cycle. if input capture input is not set, timer g functions as an 8-bit interval timer. 1. features features of timer g are given below. ? /64, /32, /2, w/2) ? ? ? ? ? ? w/2 is selected as the internal clock. ?
216 2. block diagram figure 9-8 shows a block diagram of timer g. pss tmg icrgf tcg icrgr noise canceler edge detector level detector irrtg w/4 tmig ncs notation: tmg tcg icrgf icrgr irrtg ncs pss : timer mode register g : timer counter g : input capture register gf : input capture register gr : timer g interrupt request flag : noise canceler select : prescaler s internal data bus figure 9-8 block diagram of timer g
217 3. pin configuration table 9-11 shows the timer g pin configuration. table 9-11 pin configuration name abbrev. i/o function input capture input tmig input input capture input pin 4. register configuration table 9-12 shows the register configuration of timer g. table 9-12 timer g registers name abbrev. r/w initial value address timer control register g tmg r/w h'00 h'ffbc timer counter g tcg h'00 input capture register gf icrgf r h'00 h'ffbd input capture register gr icrgr r h'00 h'ffbe clock stop register 1 ckstpr1 r/w h'ff h'fffa 9.5.2 register descriptions 1. timer counter (tcg) tcg7 tcg2 tcg1 tcg0 tcg6 tcg5 tcg4 tcg3 76543210 0 0000000 bit: initial value: read/write: tcg is an 8-bit up-counter which is incremented by clock input. the input clock is selected by bits cks1 and cks0 in tmg. tmig in pmr1 is set to 1 to operate tcg as an input capture timer, or cleared to 0 to operate tcg as an interval timer*. in input capture timer operation, the tcg value can be cleared by the rising edge, falling edge, or both edges of the input capture input signal, according to the setting made in tmg. when tcg overflows from h'ff to h'00, if ovie in tmg is 1, irrtg is set to 1 in irr2, and if ientg in ienr2 is 1, an interrupt request is sent to the cpu. for details of the interrupt, see 3.3, interrupts.
218 tcg cannot be read or written by the cpu. it is initialized to h'00 upon reset. note: * an input capture signal may be generated when tmig is modified. 2. input capture register gf (icrgf) icrgf7 icrgf2 icrgf1 icrgf0 icrgf6 icrgf5 icrgf4 icrgf3 76543210 0 0000000 r rrr rrr r bit: initial value: read/write: icrgf is an 8-bit read-only register. when a falling edge of the input capture input signal is detected, the current tcg value is transferred to icrgf. if iiegs in tmg is 1 at this time, irrtg is set to 1 in irr2, and if ientg in ienr2 is 1, an interrupt request is sent to the cpu. for details of the interrupt, see 3.3, interrupts. to ensure dependable input capture operation, the pulse width of the input capture input signal must be at least 2 or 2 sub (when the noise canceler is not used). icrgf is initialized to h'00 upon reset. 3. input capture register gr (icrgr) icrgr7 icrgr2 icrgr1 icrgr0 icrgr6 icrgr5 icrgr4 icrgr3 76543210 0 0000000 r rrr rrr r bit: initial value: read/write: icrgr is an 8-bit read-only register. when a rising edge of the input capture input signal is detected, the current tcg value is transferred to icrgr. if iiegs in tmg is 1 at this time, irrtg is set to 1 in irr2, and if ientg in ienr2 is 1, an interrupt request is sent to the cpu. for details of the interrupt, see 3.3, interrupts. to ensure dependable input capture operation, the pulse width of the input capture input signal must be at least 2 or 2 sub (when the noise canceler is not used). icrgr is initialized to h'00 upon reset.
219 4. timer mode register g (tmg) ovfh cclr0 cks1 cks0 ovfl ovie iiegs cclr1 76543210 0 0000000 r/(w) * r/w r/w r/w r/(w) * r/w r/w r/w bit: initial value: read/write: note: * bits 7 and 6 can only be written with 0, for flag clearing. tmg is an 8-bit read/write register that performs tcg clock selection from four internal clock sources, counter clear selection, and edge selection for the input capture input signal interrupt request, controls enabling of overflow interrupt requests, and also contains the overflow flags. tmg is initialized to h'00 upon reset. bit 7: timer overflow flag h (ovfh) bit 7 is a status flag indicating that tcg has overflowed from h'ff to h'00 when the input capture input signal is high. this flag is set by hardware and cleared by software. it cannot be set by software. bit 7 ovfh description 0 clearing conditions: after reading ovfh = 1, cleared by writing 0 to ovfh (initial value) 1 setting conditions: set when tcg overflows from h'ff to h'00 bit 6: timer overflow flag l (ovfl) bit 6 is a status flag indicating that tcg has overflowed from h'ff to h'00 when the input capture input signal is low, or in interval operation. this flag is set by hardware and cleared by software. it cannot be set by software. bit 6 ovfl description 0 clearing conditions: after reading ovfl = 1, cleared by writing 0 to ovfl (initial value) 1 setting conditions: set when tcg overflows from h'ff to h'00
220 bit 5: timer overflow interrupt enable (ovie) bit 5 selects enabling or disabling of interrupt generation when tcg overflows. bit 5 ovie description 0 tcg overflow interrupt request is disabled (initial value) 1 tcg overflow interrupt request is enabled bit 4: input capture interrupt edge select (iiegs) bit 4 selects the input capture input signal edge that generates an interrupt request. bit 4 iiegs description 0 interrupt generated on rising edge of input capture input signal (initial value) 1 interrupt generated on falling edge of input capture input signal bits 3 and 2: counter clear 1 and 0 (cclr1, cclr0) bits 3 and 2 specify whether or not tcg is cleared by the rising edge, falling edge, or both edges of the input capture input signal. bit 3 cclr1 bit 2 cclr0 description 0 0 tcg clearing is disabled (initial value) 0 1 tcg cleared by falling edge of input capture input signal 1 0 tcg cleared by rising edge of input capture input signal 1 1 tcg cleared by both edges of input capture input signal bits 1 and 0: clock select (cks1, cks0) bits 1 and 0 select the clock input to tcg from among four internal clock sources. bit 1 cks1 bit 0 cks0 description 0 0 internal clock: counting on /64 (initial value) 0 1 internal clock: counting on /32 1 0 internal clock: counting on /2 1 1 internal clock: counting on w/4
221 5. clock stop register 1 (ckstpr1) bit 7654 3210 s1ckstp s31ckstp s32ckstp adckstp tgckstp tfckstp tcckstp tackstp initial value 1111 1111 read/write r/w r/w r/w r/w r/w r/w r/w r/w ckstpr1 is an 8-bit read/write register that performs module standby mode control for peripheral modules. only the bit relating to timer g is described here. for details of the other bits, see the sections on the relevant modules. bit 3: timer g module standby mode control (tgckstp) bit 3 controls setting and clearing of module standby mode for timer g. tgckstp description 0 timer g is set to module standby mode 1 timer g module standby mode is cleared (initial value) 9.5.3 noise canceler the noise canceler consists of a digital low-pass filter that eliminates high-frequency component noise from the pulses input from the input capture input pin. the noise canceler is set by ncs* in pmr3. figure 9-9 shows a block diagram of the noise canceler. c dq latch c dq latch c dq latch c dq latch c dq latch match detector noise canceler output sampling clock input capture input signal sampling clock ? ? figure 9-9 noise canceler block diagram
222 the noise canceler consists of five latch circuits connected in series and a match detector circuit. when the noise cancellation function is not used (ncs = 0), the system clock is selected as the sampling clock when the noise cancellation function is used (ncs = 1), the sampling clock is the internal clock selected by cks1 and cks0 in tmg, the input capture input is sampled on the rising edge of this clock, and the data is judged to be correct when all the latch outputs match. if all the outputs do not match, the previous value is retained. after a reset, the noise canceler output is initialized when the falling edge of the input capture input signal has been sampled five times. therefore, after making a setting for use of the noise cancellation function, a pulse with at least five times the width of the sampling clock is a dependable input capture signal. even if noise cancellation is not used, an input capture input signal pulse width of at least 2 or 2 sub is necessary to ensure that input capture operations are performed properly note: * an input capture signal may be generated when the ncs bit is modified. figure 9-10 shows an example of noise canceler timing. in this example, high-level input of less than five times the width of the sampling clock at the input capture input pin is eliminated as noise. input capture input signal sampling clock noise canceler output eliminated as noise figure 9-10 noise canceler timing (example)
223 9.5.4 operation timer g is an 8-bit timer with built-in input capture and interval functions. 1. timer g functions timer g is an 8-bit up-counter with two functions, an input capture timer function and an interval timer function. the operation of these two functions is described below. a. input capture timer operation when the tmig bit is set to 1 in port mode register 1 (pmr1), timer g functions as an input capture timer*. in a reset, timer mode register g (tmg), timer counter g (tcg), input capture register gf (icrgf), and input capture register gr (icrgr) are all initialized to h'00. following a reset, tcg starts incrementing on the /64 internal clock. the input clock can be selected from four internal clock sources by bits cks1 and cks0 in tmg. when a rising edge/falling edge is detected in the input capture signal input from the tmig pin, the tcg value at that time is transferred to icrgr/icrgf. when the edge selected by iiegs in tmg is input, irrtg is set to 1 in irr2, and if the ientg bit in ienr2 is 1 at this time, an interrupt request is sent to the cpu. for details of the interrupt, see 3.3., interrupts. tcg can be cleared by a rising edge, falling edge, or both edges of the input capture signal, according to the setting of bits cclr1 and cclr0 in tmg. if tcg overflows when the input capture signal is high, the ovfh bit is set in tmg; if tcg overflows when the input capture signal is low, the ovfl bit is set in tmg. if the ovie bit in tmg is 1 when these bits are set, irrtg is set to 1 in irr2, and if the ientg bit in ienr2 is 1, timer g sends an interrupt request to the cpu. for details of the interrupt, see 3.3., interrupts. timer g has a built-in noise canceler that enables high-frequency component noise to be eliminated from pulses input from the tmig pin. for details, see 9.5.3, noise canceler. note: * an input capture signal may be generated when tmig is modified. b. interval timer operation when the tmig bit is cleared to 0 in pmr1, timer g functions as an interval timer. following a reset, tcg starts incrementing on the /64 internal clock. the input clock can be selected from four internal clock sources by bits cks1 and cks0 in tmg. tcg increments on the selected clock, and when it overflows from h'ff to h'00, the ovfl bit is set to 1 in tmg. if the ovie bit in tmg is 1 at this time, irrtg is set to 1 in irr2, and if the ientg bit in ienr2 is 1, timer g sends an interrupt request to the cpu. for details of the interrupt, see 3.3., interrupts.
224 2. increment timing tcg is incremented by internal clock input. bits cks1 and cks0 in tmg select one of four internal clock sources ( /64, /32, /2, or w/4) created by dividing the system clock ( ) or watch clock ( w). 3. input capture input timing a. without noise cancellation function for input capture input, dedicated input capture functions are provided for rising and falling edges. figure 9-11 shows the timing for rising/falling edge input capture input. input capture input signal input capture signal f input capture signal r figure 9-11 input capture input timing (without noise cancellation function) b. with noise cancellation function when noise cancellation is performed on the input capture input, the passage of the input capture signal through the noise canceler results in a delay of five sampling clock cycles from the input capture input signal edge.
225 figure 9-12 shows the timing in this case. input capture input signal sampling clock noise canceler output input capture signal r figure 9-12 input capture input timing (with noise cancellation function) 4. timing of input capture by input capture input figure 9-13 shows the timing of input capture by input capture input input capture signal tcg n-1 n n h'xx n+1 input capture register figure 9-13 timing of input capture by input capture input
226 5. tgc clear timing tcg can be cleared by the rising edge, falling edge, or both edges of the input capture input signal. figure 9-14 shows the timing for clearing by both edges. input capture input signal input capture signal f input capture signal r tcg n n h'00 h'00 figure 9-14 tcg clear timing
227 6. timer g operation modes timer g operation modes are shown in table 9-13. table 9-13 timer g operation modes operation mode reset active sleep watch subactive subsleep standby module standby tcg input capture reset functions * functions * functions/ halted * functions/ halted * functions/ halted * halted halted interval reset functions * functions * functions/ halted * functions/ halted * functions/ halted * halted halted icrgf reset functions * functions * functions/ halted * functions/ halted * functions/ halted * held held icrgr reset functions * functions * functions/ halted * functions/ halted * functions/ halted * held held tmg reset functions held held functions held held held note: * when w/4 is selected as the tcg internal clock in active mode or sleep mode, since the system clock and internal clock are mutually asynchronous, synchronization is maintained by a synchronization circuit. this results in a maximum count cycle error of 1/ (s). when w/4 is selected as the tcg internal clock in watch mode, tcg and the noise canceler operate on the w/4 internal clock without regard to the subclock ( w/8, w/4, w/2). note that when another internal clock is selected, tcg and the noise canceler do not operate, and input of the input capture input signal does not result in input capture. to operate the timer g in subactive mode or subsleep mode, select w/4 as the tcg internal clock and w/2 as the subclock sub . note that when other internal clock is selected, or when w/8 or w/4 is selected as the subclock sub , tcg and the noise canceler do not operate. 9.5.5 application notes 1. internal clock switching and tcg operation depending on the timing, tcg may be incremented by a switch between difference internal clock sources. table 9-14 shows the relation between internal clock switchover timing (by write to bits cks1 and cks0) and tcg operation. when tcg is internally clocked, an increment pulse is generated on detection of the falling edge of an internal clock signal, which is divided from the system clock ( ) or subclock ( w). for this reason, in a case like no. 3 in table 9-14 where the switch is from a high clock signal to a low clock signal, the switchover is seen as a falling edge, causing tcg to increment.
228 table 9-14 internal clock switching and tcg operation no. clock levels before and after modifying bits cks1 and cks0 tcg operation 1 goes from low level to low level clock before switching clock after switching count clock tcg n n+1 write to cks1 and cks0 2 goes from low level to high level clock before switching clock before switching count clock tcg n n+1 n+2 write to cks1 and cks0 3 goes from high level to low level * tcg n n+1 n+2 clock before switching clock before switching count clock write to cks1 and cks0
229 no. clock levels before and after modifying bits cks1 and cks0 tcg operation 4 goes from high level to high level tcg n n+1 n+2 clock before switching clock before switching count clock write to cks1 and cks0 note: * the switchover is seen as a falling edge, and tcg is incremented. 2. notes on port mode register modification the following points should be noted when a port mode register is modified to switch the input capture function or the input capture input noise canceler function. ?
230 table 9-15 input capture input signal input edges due to input capture input pin switching, and conditions for their occurrence input capture input signal input edge conditions generation of rising edge when tmig is modified from 0 to 1 while the tmig pin is high when ncs is modified from 0 to 1 while the tmig pin is high, then tmig is modified from 0 to 1 before the signal is sampled five times by the noise canceler generation of falling edge when tmig is modified from 1 to 0 while the tmig pin is high when ncs is modified from 0 to 1 while the tmig pin is low, then tmig is modified from 0 to 1 before the signal is sampled five times by the noise canceler when ncs is modified from 0 to 1 while the tmig pin is high, then tmig is modified from 1 to 0 after the signal is sampled five times by the noise canceler note: when the p1 3 pin is not set as an input capture input pin, the timer g input capture input signal is low. ? table 9-16 input capture input signal input edges due to noise canceler function switching, and conditions for their occurrence input capture input signal input edge conditions generation of rising edge when the tmig pin level is switched from low to high while tmig is set to 1, then ncs is modified from 0 to 1 before the signal is sampled five times by the noise canceler generation of falling edge when the tmig pin level is switched from high to low while tmig is set to 1, then ncs is modified from 1 to 0 before the signal is sampled five times by the noise canceler
231 when the pin function is switched and an edge is generated in the input capture input signal, if this edge matches the edge selected by the input capture interrupt select (iiegs) bit, the interrupt request flag will be set to 1. the interrupt request flag should therefore be cleared to 0 before use. figure 9-15 shows the procedure for port mode register manipulation and interrupt request flag clearing. when switching the pin function, set the interrupt-disabled state before manipulating the port mode register, then, after the port mode register operation has been performed, wait for the time required to confirm the input capture input signal as an input capture signal (at least two system clocks when the noise canceler is not used; at least five sampling clocks when the noise canceler is used), before clearing the interrupt enable flag to 0. there are two ways of preventing interrupt request flag setting when the pin function is switched: by controlling the pin level so that the conditions shown in tables 9-16 and 9-17 are not satisfied, or by setting the opposite of the generated edge in the iiegs bit in tmg. set i bit to 1 in ccr manipulate port mode register tmig confirmation time clear interrupt request flag to 0 clear i bit to 0 in ccr disable interrupts. (interrupts can also be disabled by manipulating the interrupt enable bit in interrupt enable register 2.) after manipulating he port mode register, wait for the tmig confirmation time (at least two system clocks when the noise canceler is not used; at least five sampling clocks when the noise canceler is used), then clear the interrupt enable flag to 0. enable interrupts figure 9-15 port mode register manipulation and interrupt enable flag clearing procedure
232 9.5.6 timer g application example using timer g, it is possible to measure the high and low widths of the input capture input signal as absolute values. for this purpose, cclr1 and cclr0 should both be set to 1 in tmg. figure 9-16 shows an example of the operation in this case. counter cleared tcg h'ff h'00 input capture input signal input capture register gf input capture register gr figure 9-16 timer g application example
233 9.6 watchdog timer 9.6.1 overview the watchdog timer has an 8-bit counter that is incremented by an input clock. if a system runaway allows the counter value to overflow before being rewritten, the watchdog timer can reset the chip internally. 1. features features of the watchdog timer are given below. ? /8192 or w/32). ? or 32/ w (from approximately 4 ms to 1000 ms when = 2.00 mhz). ? /8192 notation: tcsrw: tcw: pss: w/32 internal data bus reset signal timer control/status register w timer counter w prescaler s figure 9-17 block diagram of watchdog timer
234 3. register configuration table 9-17 shows the register configuration of the watchdog timer. table 9-17 watchdog timer registers name abbrev. r/w initial value address timer control/status register w tcsrw r/w h'aa h'ffb2 timer counter w tcw r/w h'00 h'ffb3 clock stop register 2 ckstp2 r/w h'ff h'fffb port mode register 3 pmr3 r/w h'00 h'ffca 9.6.2 register descriptions 1. timer control/status register w (tcsrw) bit initial value read/write 7 b6wi 1 r 6 tcwe 0 r/w 5 b4wi 1 r 4 tcsrwe 0 r/w 3 b2wi 1 r 0 wrst 0 r/w 2 wdon 0 r/w 1 b0wi 1 r * note: * ** * write is permitted only under certain conditions, which are given in the descriptions of the individual bits. tcsrw is an 8-bit read/write register that controls write access to tcw and tcsrw itself, controls watchdog timer operations, and indicates operating status. bit 7: bit 6 write inhibit (b6wi) bit 7 controls the writing of data to bit 6 in tcsrw. bit 7 b6wi description 0 bit 6 is write-enabled 1 bit 6 is write-protected (initial value) this bit is always read as 1. data written to this bit is not stored.
235 bit 6: timer counter w write enable (tcwe) bit 6 controls the writing of data to tcw. bit 6 tcwe description 0 data cannot be written to tcw (initial value) 1 data can be written to tcw bit 5: bit 4 write inhibit (b4wi) bit 5 controls the writing of data to bit 4 in tcsrw. bit 5 b4wi description 0 bit 4 is write-enabled 1 bit 4 is write-protected (initial value) this bit is always read as 1. data written to this bit is not stored. bit 4: timer control/status register w write enable (tcsrwe) bit 4 controls the writing of data to tcsrw bits 2 and 0. bit 4 tcsrwe description 0 data cannot be written to bits 2 and 0 (initial value) 1 data can be written to bits 2 and 0 bit 3: bit 2 write inhibit (b2wi) bit 3 controls the writing of data to bit 2 in tcsrw. bit 3 b2wi description 0 bit 2 is write-enabled 1 bit 2 is write-protected (initial value) this bit is always read as 1. data written to this bit is not stored.
236 bit 2: watchdog timer on (wdon) bit 2 enables watchdog timer operation. bit 2 wdon description 0 watchdog timer operation is disabled clearing conditions: reset, or when tcsrwe = 1 and 0 is written in both b2wi and wdon (initial value) 1 watchdog timer operation is enabled setting conditions: when tcsrwe = 1 and 0 is written in b2wi and 1 is written in wdon counting starts when this bit is set to 1, and stops when this bit is cleared to 0. bit 1: bit 0 write inhibit (b0wi) bit 1 controls the writing of data to bit 0 in tcsrw. bit 1 b0wi description 0 bit 0 is write-enabled 1 bit 0 is write-protected (initial value) this bit is always read as 1. data written to this bit is not stored. bit 0: watchdog timer reset (wrst) bit 0 indicates that tcw has overflowed, generating an internal reset signal. the internal reset signal generated by the overflow resets the entire chip. wrst is cleared to 0 by a reset from the res bit 0 wrst description 0 clearing conditions: reset by res
237 2. timer counter w (tcw) bit initial value read/write 7 tcw7 0 r/w 6 tcw6 0 r/w 5 tcw5 0 r/w 4 tcw4 0 r/w 3 tcw3 0 r/w 0 tcw0 0 r/w 2 tcw2 0 r/w 1 tcw1 0 r/w tcw is an 8-bit read/write up-counter, which is incremented by internal clock input. the input clock is /8192 or w/32. the tcw value can always be written or read by the cpu. when tcw overflows from h'ff to h'00, an internal reset signal is generated and wrst is set to 1 in tcsrw. upon reset, tcw is initialized to h'00. 3. clock stop register 2 (ckstpr2) bit 7654 3210 aeckstp wdckstp pwckstp ldckstp initial value 1111 1111 read/write r/w r/w r/w r/w ckstpr2 is an 8-bit read/write register that performs module standby mode control for peripheral modules. only the bit relating to the watchdog timer is described here. for details of the other bits, see the sections on the relevant modules. bit 2: watchdog timer module standby mode control (wdckstp) bit 2 controls setting and clearing of module standby mode for the watchdog timer. wdckstp description 0 watchdog timer is set to module standby mode 1 watchdog timer module standby mode is cleared (initial value) note: wdckstp is valid when the wdon bit is cleared to 0 in timer control/status register w (tcsrw). if wdckstp is set to 0 while wdon is set to 1 (during watchdog timer operation), 0 will be set in wdckstp but the watchdog timer will continue its watchdog function and will not enter modulep standby mode. when the watchdog function ends and wdon is cleared to 0 by software, the wdckstp setting will become valid and the watchdog timer will enter module standby mode.
238 4. port mode register 3 (pmr3) pmr3 is an 8-bit read/write register, mainly controlling the selection of pin functions for port 3 pins. only the bit relating to the watchdog timer is described here. for details of the other bits, see section 8, i/o ports. bit 5: watchdog timer source clock select (wdcks) wdcks description 0 /8192 selected (initial value) 1 w/32 selected note: wdcks can be set when wdon has been cleared to 0. 9.6.3 timer operation the watchdog timer has an 8-bit counter (tcw) that is incremented by clock input ( /8192 or w/32). the input clock is selected by bit wdcks in port mode register 3 (pmr3): /8192 is selected when wdcks is cleared to 0, and w/32 when set to 1. when tcsrwe = 1 in tcsrw, if 0 is written in b2wi and 1 is simultaneously written in wdon, tcw starts counting up. when the tcw count value reaches h'ff, the next clock input causes the watchdog timer to overflow, and an internal reset signal is generated one base clock ( or sub) cycle later. the internal reset signal is output for 512 clock cycles of the osc clock. it is possible to write to tcw, causing tcw to count up from the written value. the overflow period can be set in the range from 1 to 256 input clocks, depending on the value written in tcw.
239 figure 9-18 shows an example of watchdog timer operations. h'f8 tcw overflow start h'f8 written in tcw h'f8 written in tcw reset internal reset signal 512 osc clock cycles h'ff h'00 tcw count value example: = 2 mhz and the desired overflow period is 30 ms. the value set in tcw should therefore be 256 8 = 248 (h'f8). 2 3 = 7.3 8192 figure 9-18 typical watchdog timer operations (example) 9.6.4 watchdog timer operation states table 9-18 summarizes the watchdog timer operation states. table 9-18 watchdog timer operation states operation mode reset active sleep watch subactive subsleep standby module standby tcw reset functions functions halted functions/ halted * halted halted halted tcsrw reset functions functions retained functions/ halted * retained retained retained note: * functions when w/32 is selected as the input clock.
240
241 section 10 serial communication interface 10.1 overview the h8/3937 series and h8/3937r series are provided with two serial communication interface (sci) channels plus one sci channel for on-chip flex decoder interfacing. the functions of the three sci channels are summarized in table 10-1. table 10-1 overview of sci functions sci name functions features sci1 (internal function) synchronous serial transfer functions ? choice of transfer data length (8 or 16 bits) ? continuous clock output function ? choice of 8 internal clocks (?1024 to ?4, w /4) or external clock ? interrupt generated on completion of transfer sci31, sci32 synchronous serial transfer functions ? 8-bit transfer data length ? transmission/reception/simultaneous transmission and reception asynchronous serial transfer functions ? multiprocessor communication function ? choice of transfer data length (5 or 7 or 8 bits) ? choice of stop bit length (1 or 2 bits) ? parity addition function ? on-chip baud rate generator ? receive error detection ? break detection ? interrupt generated on completion of transfer or in case of error
242 10.2 sci1 [chip internal function] 10.2.1 overview serial communication interface 1 (sci1) can carry out 8-bit or 16-bit serial data transfer in synchronous mode. sci1 is an internal function that performs interfacing to the flex decoder incorporated in the chip. it cannot be connected to an ic outside the chip for data communication use. 1. features features of sci1 are listed below. ? choice of 8-bit or 16-bit transfer data length ? choice of 8 internal clocks (?1024, ?256, ?64, ?32, ?16, ?8, ?4, or w /4) as clock source ? interrupt request generated on completion of transfer
243 2. block diagram figure 10-1 shows a block diagram of sci1. w /4 sck1 si 1 so 1 pss transmit/receive control circuit scr1 scsr1 transfer bit counter sdru sdrl irrs1 transfer bit counter notation: scr1: serial control register 1 scsr1: serial control status register 1 sdru: serial data register u sdrl: serial data register l irrs1: serial 1 interrupt request flag pss: prescaler s figure 10-1 sci1 block diagram
244 3. i/o configuration table 10-2 shows the sci1 i/o configuration. table 10-2 sci1 i/o configuration name abbrev. i/o function sci1 clock sck 1 i/o sci1 clock input/output sci1 data input si 1 input sci1 receive data input sci1 data output so 1 output sci1 transmit data output 4. register configuration table 10-3 shows the sci1 register configuration. table 10-3 registers name abbrev. r/w initial value address serial control register 1 scr1 r/w h'00 h'ffa0 serial control status register 1 scsr1 r/w h'9c h'ffa1 serial data register u sdru r/w undefined h'ffa2 serial data register l sdrl r/w undefined h'ffa3 clock stop register 1 ckstpr1 r/w h'ff h'fffa 10.2.2 register descriptions 1. serial control register 1 (scr1) bit initial value read/write 7 snc1 0 r/w 6 snc0 0 r/w 5 mrkon 0 r/w 4 ltch 0 r/w 3 cks3 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w scr1 is an 8-bit read/write register that controls the operating mode, serial clock source, and prescaler division ratio. upon reset, scr1 is initialized to h'00. if this register is written to during transfer, transfer will be halted.
245 bits 7 and 6: operating mode select 1 and 0 (snc1, snc0) bits 7 and 6 select the operating mode. bit 7 snc1 bit 6 snc0 description 0 0 8-bit synchronous mode (initial value) 0 1 16-bit synchronous mode 1 0 continuous clock output mode * 1 1 1 reserved * 2 notes: 1. use si1 and so1 as ports. 2. do not set bits snc1 and snc0 to 11. bit 5: tail mark control (mrkon) bit 5 controls tail mark output after transfer of 8-bit or 16-bit data. bit 5 mrkon description 0 tail mark is not output (synchronous mode) (initial value) 1 tail mark is output (ssb mode) * note: * sci1 is an internal function that performs interfacing to the on-chip flex decoder. it cannot be used with ssb mode selected. bit 4: latch tail select (ltch) bit 4 selects whether latch tail or hold tail is output as the tail mark when mrkon = 1 (i.e. in ssb mode). bit 4 ltch description 0 hold tail is output (initial value) 1 latch tail is output
246 bit 3: clock source select 3 (cks3) bit 3 selects the clock source to be supplied and sets the sck 1 to input or output mode. bit 3 cks3 description 0 clock source is prescaler s, sck 1 is output (initial value) 1 clock source is external clock, sck 1 is input * note: * sci1 is an internal function that performs interfacing to the on-chip flex decoder. it cannot be used with sck1 input selected. bits 2 to 0: clock select 2 to 0 (cks2 to cks0) when cks3 is cleared to 0, bits 2 to 0 selects the prescaler division ratio and the serial clock cycle. bit 2 bit 1 bit 0 serial clock cycle cks2 cks1 cks0 prescaler division ratio ?= 2.5 mhz 000 /1024 (initial value) 409.6 s 001 /256 102.4 s 010 /64 25.6 s 011 /32 12.8 s 100 /16 6.4 s 101 /8 3.2 s 110 /4 1.6 s 111 w /4 50 s or 104.2 s 2. serial control status register 1 (scsr1) bit initial value read/write 7 1 6 sol 0 r/w 5 orer 0 r/(w) * 4 1 3 1 0 stf 0 r/w 2 1 1 mtrf 0 r note: * only a write of 0 for flag clearing is possible. scsr1 is an 8-bit register that indicates the operational and error status of sci1. upon reset, scsr1 is initialized to h'9c.
247 bit 7: reserved bit bits 7 is reserved; it is always read as 1 and cannot be modified. bit 6: extension data bit (sol) the sol bit changes the output level of the so 1 . when read, sol returns the output level of the so 1 . after transfer is completed, so 1 output retains the value of the last bit of the transmit data, and therefore the so 1 output level can be changed by manipulating this bit before or after transmission. however, the sol bit setting becomes invalid when the next transmission starts*. therefore, when changing the so 1 output level after transmission, a write operation must be performed on the sol bit each time transmission is completed. writing to this register during data transfer will cause incorrect operation, so this register should not be manipulated during transmission. note: * the sol bit setting is also invalid in ssb mode. bit 6 sol description 0 read so 1 output level is low (initial value) write changes so 1 output to low level 1 read so 1 output level is high write changes so 1 output to high level bit 5: overrun error flag (orer) bit 5 indicates that an overrun error has occurred when using an external clock. if extra pulses are superimposed on the regular serial clock due to extraneous noise, etc., the transfer data cannot be guaranteed. if the clock is input after transfer is completed, this will be interpreted as an overrun state and this bit will be set to 1. bit 5 orer description 0 clearing conditions: after reading orer = 1, cleared by writing 0 to orer (initial value) 1 setting conditions: when an external clock is used and the clock is input after transfer is completed bits 4 to 2: reserved bits bits 4 to 2 are reserved; they are always read as 1 and cannot be modified.
248 bit 1: tail mark transmission flag (mtrf) when mrkon = 1, bit 1 indicates that a tail mark is being transmitted. mtrf is a read-only bit, and cannot be modified. bit 1 mtrf description 0 idle state, or 8-bit/16-bit data transfer in progress (initial value) 1 tail mark transmission in progress bit 0: start flag (stf) the stf bit controls the start of transfer operations. sci1 transfer operation is started when this bit is set to 1. stf remains set to 1 during transfer and while sci1 is waiting for a start bit, and is cleared to 0 when transfer ends. bit 0 stf description 0 read transfer operation stopped (initial value) write invalid 1 read transfer operation in progress write starts transfer operation 3. serial data register u (sdru) bit initial value read/write 7 sdru7 undefined r/w 6 sdru6 undefined r/w 5 sdru5 undefined r/w 4 sdru4 undefined r/w 3 sdru3 undefined r/w 0 sdru0 undefined r/w 2 sdru2 undefined r/w 1 sdru1 undefined r/w sdru is an 8-bit read/write register used as the data register for the upper 8 bits in 16-bit transfer (while sdrl is used for the lower 8 bits). the data written into sdru is output to sdrl in lsb-first order. in the replacement process, data is input lsb-first from the si 1 pin, and the data is shifted in the msb
249 4. serial data register l (sdrl) bit initial value read/write 7 sdrl7 undefined r/w 6 sdrl6 undefined r/w 5 sdrl5 undefined r/w 4 sdrl4 undefined r/w 3 sdrl3 undefined r/w 0 sdrl0 undefined r/w 2 sdrl2 undefined r/w 1 sdrl1 undefined r/w sdrl is an 8-bit read/write register used as the data register in 8-bit transfer, and as the data register for the lower 8 bits in 16-bit transfer (while sdru is used for the upper 8 bits). in 8-bit transfer, the data written into sdrl is output from the so 1 in lsb-first order. in the replacement process, data is input lsb-first from the si 1 , and the data is shifted in the msb bit 7654 3210 s1ckstp s31ckstp s32ckstp adckstp tgckstp tfckstp tcckstp tackstp initial value 1111 1111 read/write r/w r/w r/w r/w r/w r/w r/w r/w ckstpr1 is an 8-bit read/write register that performs module standby mode control for peripheral modules. only the bit relating to sci1 is described here. for details of the other bits, see the sections on the relevant modules.
250 bit 7: sci1 module standby mode control (s1ckstp) bit 7 controls setting and clearing of module standby mode for sci1. bit 7 s1ckstp description 0 sci1 is set to module standby mode * 1 1 sci1 module standby mode is cleared (initial value) note: * setting to module standby mode resets scr1, scsr1, sdru and sdrl. 10.2.3 operation either 8-bit or 16-bit transfer data can be selected as the transfer format. eight internal clocks can be selected as the clock source. 1. clock the serial clock can be selected from 8 internal clocks. when an internal clock is selected, the sck 1 functions as the clock output. when continuous clock output mode is set (snc1, snc0 = 10 in scr1), the clock selected by bits cks2 to cks0 ( /1024 to w /4) is output continuously from the sck 1 . 2. data transfer format the sci1 transfer format is shown in figure 10-2. lsb-first transfer is used (i.e. transmission and reception are performed starting with the least significant bit of the transfer data). transfer data is output from one falling edge of the serial clock until the next falling edge. receive data is latched at the rising edge of the serial clock. bit 0 so 1 /si 1 sck 1 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 figure 10-2 transfer format
251 3. data transfer operations transmitting: the procedure for transmitting data is as follows. (1) set both so1 and sck1 to 1 in pmr2 to designate the so1 and sck1 functions. (2) clear snc1 in scr1 to 0, clear or set snc0 to 0 or 1, and clear mrkon to 0, to select 8-bit synchronous mode or 16-bit synchronous mode, and select the serial clock with bits cks3 to cks0. when data is written to scr1 with mrkon in scr1 cleared to 0, the internal state of sci1 is initialized. (3) write the transfer data to sdrl/sdru. 8-bit transfer mode: sdrl 16-bit transfer mode: upper byte to sdru, lower byte to sdrl (4) when stf is set to 1 in scsr1, sci1 starts operating and transmit data is output from the so1. (5) after transmission is completed, irrs1 is set to 1 in irr1. when an internal clock is used, the serial clock is output from the sck 1 simultaneously with transmit data output. when transmission ends, the serial clock is not output until the start flag is next set to 1. during this interval, the so 1 continuously outputs the last bit of the previous data. while transmission is halted, the output value of the so 1 can be changed by means of the sol bit in scsr1. receiving: the procedure for receiving data is as follows. (1) set both si1 and sck1 to 1 in pmr2 to designate the si1 and sck1 functions. (2) clear snc1 in scr1 to 0, clear or set snc0 to 0 or 1, and clear mrkon to 0, to select 8-bit synchronous mode or 16-bit synchronous mode, and select the serial clock with bits cks3 to cks0. when data is written to scr1 with mrkon in scr1 cleared to 0, the internal state of sci1 is initialized. (3) when stf is set to 1 in scsr1, sci1 starts operating and receive data is taken in from the si1. (4) after reception is completed, irrs1 is set to 1 in irr1. (5) read the transfer data from sdrl/sdru. 8-bit transfer mode: sdrl 16-bit transfer mode: upper byte from sdru, lower byte from sdrl
252 simultaneous transmitting and receiving: the procedure for simultaneously transmitting and receiving data is as follows. (1) set so1, si1, and sck1 all to 1 in pmr2 to designate the so1, si1, and sck1 functions. (2) clear snc1 in scr1 to 0, clear or set snc0 to 0 or 1, and clear mrkon to 0, to select 8-bit synchronous mode or 16-bit synchronous mode, and select the serial clock with bits cks3 to cks0. when data is written to scr1 with mrkon in scr1 cleared to 0, the internal state of sci1 is initialized. (3) write the transfer data to sdrl/sdru. 8-bit transfer mode: sdrl 16-bit transfer mode: upper byte to sdru, lower byte to sdrl (4) when stf is set to 1 in scsr1, sci1 starts operating and transmit data is output from the so1, or receive data is input from the si1. (5) after transmission/reception is completed, irrs1 is set to 1 in irr1. (6) read the transfer data from sdrl/sdru. 8-bit transfer mode: sdrl 16-bit transfer mode: upper byte from sdru, lower byte from sdrl when an internal clock is used, the serial clock is output from the sck 1 simultaneously with transmit data output. when transmission ends, the serial clock is not output until the start flag is next set to 1. during this interval, the so 1 continuously outputs the last bit of the previous data. while transmission is halted, the output value of the so 1 pin can be changed by means of the sol bit in scsr1. 10.2.4 interrupt source sci1 has one interrupt source: transfer completion. when sci1 completes transfer, irrs1 is set to 1 in irr1. the sci1 interrupt source can be enabled or disabled by the iens1 bit in ienr1. for details, see 3.3, interrupts.
253 10.2.5 application note (1) conditions for use of sci1 in subactive mode and subsleep mode in subactive or subsleep mode, sci1 can be used only when the cpu operation clock is w /2. (2) confirming the end of serial transfer do not read or write to scsr1 during serial transfer. the following two methods can be used to confirm the end of serial transfer: (a) using sci1 interrupt exception handling set the iens1 bit to 1 in ienr1 and execute interrupt exception handling. (b) performing irr1 polling with sci1 interrupts disabled (iens1 = 0 in ienr1), confirm that the irrs1 bit in irr1 has been set to 1.
254 10.3 sci3 10.3.1 overview in addition to sci1, the h8/3937 series and h8/3937r series have two serial communication interfaces, sci31 and sci32, with identical functions. in this manual, the generic term sci3 is used to refer to both of these scis. serial communication interface 3 (sci3) can carry out serial data communication in either asynchronous or synchronous mode. it is also provided with a multiprocessor communication function that enables serial data to be transferred among processors. 1. features features of sci3 are listed below. ? ? data length 7, 8, 5 bits stop bit length 1 or 2 bits parity even, odd, or none multiprocessor bit 1 or 0 receive error detection parity, overrun, and framing errors break detection break detected by reading the rxd 3x pin level directly when a framing error occurs
255 ? data length 8 bits receive error detection overrun errors ? ? ? ?
256 2. block diagram figure 10-3 shows a block diagram of sci3. clock txd rxd sck brr smr scr3 ssr tdr rdr tsr rsr spcr transmit/receive control circuit internal data bus notation: rsr: rdr: tsr: tdr: smr: scr3: ssr: brr: brc: spcr: receive shift register receive data register transmit shift register transmit data register serial mode register serial control register 3 serial status register bit rate register bit rate counter serial port control register interrupt request (tei, txi, rxi, eri) 3x internal clock ( /64, /16, w/2, ) external clock brc baud rate generator figure 10-3 sci3 block diagram
257 3. pin configuration table 10-4 shows the sci3 pin configuration. table 10-4 pin configuration name abbrev. i/o function sci3 clock sck 3x i/o sci3 clock input/output sci3 receive data input rxd 3x input sci3 receive data input sci3 transmit data output txd 3x output sci3 transmit data output 4. register configuration table 10-5 shows the sci3 register configuration. table 10-5 registers name abbrev. r/w initial value address serial mode register smr r/w h'00 h'ffa8/ff98 bit rate register brr r/w h'ff h'ffa9/ff99 serial control register 3 scr3 r/w h'00 h'ffaa/ff9a transmit data register tdr r/w h'ff h'ffab/ff9b serial data register ssr r/w h'84 h'ffac/ff9c receive data register rdr r h'00 h'ffad/ff9d transmit shift register tsr protected receive shift register rsr protected bit rate counter brc protected clock stop register 1 ckstpr1 r/w h'ff h'fffa serial port control register spcr r/w h'c0 h'ff91
258 10.3.2 register descriptions 1. receive shift register (rsr) bit read/write 7 6 5 4 3 0 2 1 rsr is a register used to receive serial data. serial data input to rsr from the rxd 3x pin is set in the order in which it is received, starting from the lsb (bit 0), and converted to parallel data. when one byte of data is received, it is transferred to rdr automatically. rsr cannot be read or written directly by the cpu. 2. receive data register (rdr) bit initial value read/write 7 rdr7 0 r 6 rdr6 0 r 5 rdr5 0 r 4 rdr4 0 r 3 rdr3 0 r 0 rdr0 0 r 2 rdr2 0 r 1 rdr1 0 r rdr is an 8-bit register that stores received serial data. when reception of one byte of data is finished, the received data is transferred from rsr to rdr, and the receive operation is completed. rsr is then able to receive data. rsr and rdr are double-buffered, allowing consecutive receive operations. rdr is a read-only register, and cannot be written by the cpu. rdr is initialized to h'00 upon reset, and in standby, watch or module standby mode.
259 3. transmit shift register (tsr) bit read/write 7 6 5 4 3 0 2 1 tsr is a register used to transmit serial data. transmit data is first transferred from tdr to tsr, and serial data transmission is carried out by sending the data to the txd 3x pin in order, starting from the lsb (bit 0). when one byte of data is transmitted, the next byte of transmit data is transferred to tdr, and transmission started, automatically. data transfer from tdr to tsr is not performed if no data has been written to tdr (if bit tdre is set to 1 in the serial status register (ssr)). tsr cannot be read or written directly by the cpu. 4. transmit data register (tdr) bit initial value read/write 7 tdr7 1 r/w 6 tdr6 1 r/w 5 tdr5 1 r/w 4 tdr4 1 r/w 3 tdr3 1 r/w 0 tdr0 1 r/w 2 tdr2 1 r/w 1 tdr1 1 r/w tdr is an 8-bit register that stores transmit data. when tsr is found to be empty, the transmit data written in tdr is transferred to tsr, and serial data transmission is started. continuous transmission is possible by writing the next transmit data to tdr during tsr serial data transmission. tdr can be read or written by the cpu at any time. tdr is initialized to h'ff upon reset, and in standby, watch or module standby mode.
260 5. serial mode register (smr) bit initial value read/write 7 com 0 r/w 6 chr 0 r/w 5 pe 0 r/w 4 pm 0 r/w 3 stop 0 r/w 0 cks0 0 r/w 2 mp 0 r/w 1 cks1 0 r/w smr is an 8-bit register used to set the serial data transfer format and to select the clock source for the baud rate generator. smr can be read or written by the cpu at any time. smr is initialized to h'00 upon reset, and in standby, watch or module standby mode. bit 7: communication mode (com) bit 7 selects whether sci3 operates in asynchronous mode or synchronous mode. bit 7 com description 0 asynchronous mode (initial value) 1 synchronous mode bit 6: character length (chr) bit 6 selects either 7 or 8 bits as the data length to be used in asynchronous mode. in synchronous mode the data length is always 8 bits, irrespective of the bit 6 setting. bit 6 chr description 0 8-bit data/5-bit data * 2 (initial value) 1 7-bit data * 1 /5-bit data * 2 notes: 1. when 7-bit data is selected, the msb (bit 7) of tdr is not transmitted. 2. when 5-bit data is selected, set both pe and mp to 1. the three most significant bits (bits 7, 6, and 5) of tdr are not transmitted.
261 bit 5: parity enable (pe) bit 5 selects whether a parity bit is to be added during transmission and checked during reception in asynchronous mode. in synchronous mode parity bit addition and checking is not performed, irrespective of the bit 5 setting. bit 5 pe description 0 parity bit addition and checking disabled * 2 (initial value) 1 parity bit addition and checking enabled * 1/ * 2 notes: 1. when pe is set to 1, even or odd parity, as designated by bit pm, is added to transmit data before it is sent, and the received parity bit is checked against the parity designated by bit pm. 2. for the case where 5-bit data is selected, see table 10-11. bit 4: parity mode (pm) bit 4 selects whether even or odd parity is to be used for parity addition and checking. the pm bit setting is only valid in asynchronous mode when bit pe is set to 1, enabling parity bit addition and checking. the pm bit setting is invalid in synchronous mode, and in asynchronous mode if parity bit addition and checking is disabled. bit 4 pm description 0 even parity * 1 (initial value) 1 odd parity * 2 notes: 1. when even parity is selected, a parity bit is added in transmission so that the total number of 1 bits in the transmit data plus the parity bit is an even number; in reception, a check is carried out to confirm that the number of 1 bits in the receive data plus the parity bit is an even number. 2. when odd parity is selected, a parity bit is added in transmission so that the total number of 1 bits in the transmit data plus the parity bit is an odd number; in reception, a check is carried out to confirm that the number of 1 bits in the receive data plus the parity bit is an odd number.
262 bit 3: stop bit length (stop) bit 3 selects 1 bit or 2 bits as the stop bit length is asynchronous mode. the stop bit setting is only valid in asynchronous mode. when synchronous mode is selected the stop bit setting is invalid since stop bits are not added. bit 3 stop description 0 1 stop bit * 1 (initial value) 1 2 stop bits * 2 notes: 1. in transmission, a single 1 bit (stop bit) is added at the end of a transmit character. 2. in transmission, two 1 bits (stop bits) are added at the end of a transmit character. in reception, only the first of the received stop bits is checked, irrespective of the stop bit setting. if the second stop bit is 1 it is treated as a stop bit, but if 0, it is treated as the start bit of the next transmit character. bit 2: multiprocessor mode (mp) bit 2 enables or disables the multiprocessor communication function. when the multiprocessor communication function is disabled, the parity settings in the pe and pm bits are invalid. the mp bit setting is only valid in asynchronous mode. when synchronous mode is selected the mp bit should be set to 0. for details on the multiprocessor communication function, see 10.1.6, multiprocessor communication function. bit 2 mp description 0 multiprocessor communication function disabled * (initial value) 1 multiprocessor communication function enabled * note: * for the case where 5-bit data is selected, see table 10-11.
263 bits 1 and 0: clock select 1 and 0 (cks1, cks0) bits 1 and 0 choose /64, /16, /2, or as the clock source for the baud rate generator. for the relation between the clock source, bit rate register setting, and baud rate, see 8, bit rate register (brr). bit 1 cks1 bit 0 cks0 description 00 clock (initial value) 01 w /2 clock * 1 / w clock * 2 10 /16 clock 11 /64 clock notes: 1. w /2 clock is selected in active (medium- and high-speed) or sleep (medium- and high- speed) mode. 2. w clock is selected in subactive or subsleep mode. sci3 can be used only when the w /2 is selected as the cpu clock in subactive or subsleep mode. 6. serial control register 3 (scr3) bit initial value read/write 7 tie 0 r/w 6 rie 0 r/w 5 te 0 r/w 4 re 0 r/w 3 mpie 0 r/w 0 cke0 0 r/w 2 teie 0 r/w 1 cke1 0 r/w scr3 is an 8-bit register for selecting transmit or receive operation, the asynchronous mode clock output, interrupt request enabling or disabling, and the transmit/receive clock source. scr3 can be read or written by the cpu at any time. scr3 is initialized to h'00 upon reset, and in standby, watch or module standby mode.
264 bit 7: transmit interrupt enable (tie) bit 7 selects enabling or disabling of the transmit data empty interrupt request (txi) when transmit data is transferred from the transmit data register (tdr) to the transmit shift register (tsr), and bit tdre in the serial status register (ssr) is set to 1. txi can be released by clearing bit tdre or bit tie to 0. bit 7 tie description 0 transmit data empty interrupt request (txi) disabled (initial value) 1 transmit data empty interrupt request (txi) enabled bit 6: receive interrupt enable (rie) bit 6 selects enabling or disabling of the receive data full interrupt request (rxi) and the receive error interrupt request (eri) when receive data is transferred from the receive shift register (rsr) to the receive data register (rdr), and bit rdrf in the serial status register (ssr) is set to 1. there are three kinds of receive error: overrun, framing, and parity. rxi can be released by clearing bit rdrf or the fer, per, or oer error flag to 0, or by clearing bit rie to 0. bit 6 rie description 0 receive data full interrupt request (rxi) and receive error interrupt request (eri) disabled (initial value) 1 receive data full interrupt request (rxi) and receive error interrupt request (eri) enabled bit 5: transmit enable (te) bit 5 selects enabling or disabling of the start of transmit operation. bit 5 te description 0 transmit operation disabled * 1 (txd pin is i/o port) (initial value) 1 transmit operation enabled * 2 (txd pin is transmit data pin) notes: 1. bit tdre in ssr is fixed at 1. 2. when transmit data is written to tdr in this state, bit tdr in ssr is cleared to 0 and serial data transmission is started. be sure to carry out serial mode register (smr) settings, and setting of bit spc31 or spc32 in spcr, to decide the transmission format before setting bit te to 1.
265 bit 4: receive enable (re) bit 4 selects enabling or disabling of the start of receive operation. bit 4 re description 0 receive operation disabled * 1 (rxd pin is i/o port) (initial value) 1 receive operation enabled * 2 (rxd pin is receive data pin) notes: 1. note that the rdrf, fer, per, and oer flags in ssr are not affected when bit re is cleared to 0, and retain their previous state. 2. in this state, serial data reception is started when a start bit is detected in asynchronous mode or serial clock input is detected in synchronous mode. be sure to carry out serial mode register (smr) settings to decide the reception format before setting bit re to 1. bit 3: multiprocessor interrupt enable (mpie) bit 3 selects enabling or disabling of the multiprocessor interrupt request. the mpie bit setting is only valid when asynchronous mode is selected and reception is carried out with bit mp in smr set to 1. the mpie bit setting is invalid when bit com is set to 1 or bit mp is cleared to 0. bit 3 mpie description 0 multiprocessor interrupt request disabled (normal receive operation) clearing conditions: when data is received in which the multiprocessor bit is set to 1 (initial value) 1 multiprocessor interrupt request enabled * note: * receive data transfer from rsr to rdr, receive error detection, and setting of the rdrf, fer, and oer status flags in ssr is not performed. rxi, eri, and setting of the rdrf, fer, and oer flags in ssr, are disabled until data with the multiprocessor bit set to 1 is received. when a receive character with the multiprocessor bit set to 1 is received, bit mpbr in ssr is set to 1, bit mpie is automatically cleared to 0, and rxi and eri requests (when bits tie and rie in serial control register 3 (scr3) are set to 1) and setting of the rdrf, fer, and oer flags are enabled.
266 bit 2: transmit end interrupt enable (teie) bit 2 selects enabling or disabling of the transmit end interrupt request (tei) if there is no valid transmit data in tdr when msb data is to be sent. bit 2 teie description 0 transmit end interrupt request (tei) disabled (initial value) 1 transmit end interrupt request (tei) enabled * note: * tei can be released by clearing bit tdre to 0 and clearing bit tend to 0 in ssr, or by clearing bit teie to 0. bits 1 and 0: clock enable 1 and 0 (cke1, cke0) bits 1 and 0 select the clock source and enabling or disabling of clock output from the sck 3x pin. the combination of cke1 and cke0 determines whether the sck 3x pin functions as an i/o port, a clock output pin, or a clock input pin. the cke0 bit setting is only valid in case of internal clock operation (cke1 = 0) in asynchronous mode. in synchronous mode, or when external clock operation is used (cke1 = 1), bit cke0 should be cleared to 0. after setting bits cke1 and cke0, set the operating mode in the serial mode register (smr). for details on clock source selection, see table 10-4 in 10.1.3, operation. bit 1 bit 0 description cke1 cke0 communication mode clock source sck 3x pin function 0 0 asynchronous internal clock i/o port * 1 synchronous internal clock serial clock output * 1 0 1 asynchronous internal clock clock output * 2 synchronous reserved 1 0 asynchronous external clock clock input * 3 synchronous external clock serial clock input 1 1 asynchronous reserved synchronous reserved notes: 1. initial value 2. a clock with the same frequency as the bit rate is output. 3. input a clock with a frequency 16 times the bit rate.
267 7. serial status register (ssr) bit initial value read/write 7 tdre 1 r/(w) 6 rdrf 0 r/(w) 5 oer 0 r/(w) 4 fer 0 r/(w) 3 per 0 r/(w) 0 mpbt 0 r/w 2 tend 1 r 1 mpbr 0 r ***** note: * only a write of 0 for flag clearing is possible. ssr is an 8-bit register containing status flags that indicate the operational status of sci3, and multiprocessor bits. ssr can be read or written by the cpu at any time, but only a write of 1 is possible to bits tdre, rdrf, oer, per, and fer. in order to clear these bits by writing 0, 1 must first be read. bits tend and mpbr are read-only bits, and cannot be modified. ssr is initialized to h'84 upon reset, and in standby, module standby, or watch mode. bit 7: transmit data register empty (tdre) bit 7 indicates that transmit data has been transferred from tdr to tsr. bit 7 tdre description 0 transmit data written in tdr has not been transferred to tsr clearing conditions: after reading tdre = 1, cleared by writing 0 to tdre when data is written to tdr by an instruction 1 transmit data has not been written to tdr, or transmit data written in tdr has been transferred to tsr setting conditions: when bit te in scr3 is cleared to 0 when data is transferred from tdr to tsr (initial value)
268 bit 6: receive data register full (rdrf) bit 6 indicates that received data is stored in rdr. bit 6 rdrf description 0 there is no receive data in rdr clearing conditions: after reading rdrf = 1, cleared by writing 0 to rdrf when rdr data is read by an instruction (initial value) 1 there is receive data in rdr setting conditions: when reception ends normally and receive data is transferred from rsr to rdr note: if an error is detected in the receive data, or if the re bit in scr3 has been cleared to 0, rdr and bit rdrf are not affected and retain their previous state. note that if data reception is completed while bit rdrf is still set to 1, an overrun error (oer) will result and the receive data will be lost. bit 5: overrun error (oer) bit 5 indicates that an overrun error has occurred during reception. bit 5 oer description 0 reception in progress or completed * 1 clearing conditions: after reading oer = 1, cleared by writing 0 to oer (initial value) 1 an overrun error has occurred during reception * 2 setting conditions: when reception is completed with rdrf set to 1 notes: 1. when bit re in scr3 is cleared to 0, bit oer is not affected and retains its previous state. 2. rdr retains the receive data it held before the overrun error occurred, and data received after the error is lost. reception cannot be continued with bit oer set to 1, and in synchronous mode, transmission cannot be continued either.
269 bit 4: framing error (fer) bit 4 indicates that a framing error has occurred during reception in asynchronous mode. bit 4 fer description 0 reception in progress or completed * 1 clearing conditions: after reading fer = 1, cleared by writing 0 to fer (initial value) 1 a framing error has occurred during reception setting conditions: when the stop bit at the end of the receive data is checked for a value of 1 at the end of reception, and the stop bit is 0 * 2 notes: 1. when bit re in scr3 is cleared to 0, bit fer is not affected and retains its previous state. 2. note that, in 2-stop-bit mode, only the first stop bit is checked for a value of 1, and the second stop bit is not checked. when a framing error occurs the receive data is transferred to rdr but bit rdrf is not set. reception cannot be continued with bit fer set to 1. in synchronous mode, neither transmission nor reception is possible when bit fer is set to 1. bit 3: parity error (per) bit 3 indicates that a parity error has occurred during reception with parity added in asynchronous mode. bit 3 per description 0 reception in progress or completed * 1 clearing conditions: after reading per = 1, cleared by writing 0 to per (initial value) 1 a parity error has occurred during reception * 2 setting conditions: when the number of 1 bits in the receive data plus parity bit does not match the parity designated by bit pm in the serial mode register (smr) notes: 1. when bit re in scr3 is cleared to 0, bit per is not affected and retains its previous state. 2. receive data in which it a parity error has occurred is still transferred to rdr, but bit rdrf is not set. reception cannot be continued with bit per set to 1. in synchronous mode, neither transmission nor reception is possible when bit fer is set to 1.
270 bit 2: transmit end (tend) bit 2 indicates that bit tdre is set to 1 when the last bit of a transmit character is sent. bit 2 is a read-only bit and cannot be modified. bit 2 tend description 0 transmission in progress clearing conditions: after reading tdre = 1, cleared by writing 0 to tdre when data is written to tdr by an instruction 1 transmission ended setting conditions: when bit te in scr3 is cleared to 0 when bit tdre is set to 1 when the last bit of a transmit character is sent (initial value) bit 1: multiprocessor bit receive (mpbr) bit 1 stores the multiprocessor bit in a receive character during multiprocessor format reception in asynchronous mode. bit 1 is a read-only bit and cannot be modified. bit 1 mpbr description 0 data in which the multiprocessor bit is 0 has been received * (initial value) 1 data in which the multiprocessor bit is 1 has been received note: * when bit re is cleared to 0 in scr3 with the multiprocessor format, bit mpbr is not affected and retains its previous state. bit 0: multiprocessor bit transfer (mpbt) bit 0 stores the multiprocessor bit added to transmit data when transmitting in asynchronous mode. the bit mpbt setting is invalid when synchronous mode is selected, when the multiprocessor communication function is disabled, and when not transmitting. bit 0 mpbt description 0 a 0 multiprocessor bit is transmitted (initial value) 1 a 1 multiprocessor bit is transmitted
271 8. bit rate register (brr) bit initial value read/write 7 brr7 1 r/w 6 brr6 1 r/w 5 brr5 1 r/w 4 brr4 1 r/w 3 brr3 1 r/w 0 brr0 1 r/w 2 brr2 1 r/w 1 brr1 1 r/w brr is an 8-bit register that designates the transmit/receive bit rate in accordance with the baud rate generator operating clock selected by bits cks1 and cks0 of the serial mode register (smr). brr can be read or written by the cpu at any time. brr is initialized to h'ff upon reset, and in standby, module standby, or watch mode. table 10-6 shows examples of brr settings in asynchronous mode. the values shown are for active (high-speed) mode. table 10-6 examples of brr settings for various bit rates (asynchronous mode) (1) osc 32.8 khz 38.4 khz 2 mhz 2.4576 mhz 4 mhz bit rate (bit/s) n n error (%) n n error (%) n n error (%) n n error (%) n n error (%) 110 cannot be used, 221 0.83 150 as error exceeds 030212 0.16 330225 0.16 200 3% 0200155 0.16 3 2 0 250 0 124 0 0 153 0.26 0 249 0 300 0100103 0.16 310212 0.16 600 000051 0.16 3000103 0.16 1200 0 25 0.16 210051 0.16 2400 0 12 0.16 200025 0.16 4800 070012 0.16 9600 030 19200 010 31250 000 010 38400 000
272 table 10-6 examples of brr settings for various bit rates (asynchronous mode) (2) osc 10 mhz 16 mhz bit rate (bit/s) n n error (%) n n error (%) 110 2 88 ?.25 2 141 ?.02 150 2 64 0.16 2 103 0.16 200 2 48 ?.35 2 77 0.16 250 2 38 0.16 2 62 ?.79 300 2 51 0.16 600 2 25 0.16 1200 0 129 0.16 0 207 0.16 2400 0 64 0.16 0 103 0.16 4800 0 51 0.16 9600 0 25 0.16 19200 0 12 0.16 31250 0 4 0070 38400 notes: 1. the setting should be made so that the error is not more than 1%. 2. the value set in brr is given by the following equation: n= osc (64 2 2n b) ?1 where b: bit rate (bit/s) n: baud rate generator brr setting (0 n 255) osc: value of osc (hz) n: baud rate generator input clock number (n = 0, 2, or 3) (the relation between n and the clock is shown in table 10-7.) 3. the error in table 10-6 is the value obtained from the following equation, rounded to two decimal places. error (%) = b (rate obtained from n, n, osc) ?r (bit rate in left-hand column in table 10-6.) r (bit rate in left-hand column in table 10-6.) 100
273 table 10-7 relation between n and clock smr setting n clock cks1 cks0 0 0 0 0 w /2 * 1 / w * 2 01 2 ?16 1 0 3 ?64 1 1 notes: 1. w /2 clock is selected in active (medium- and high-speed) or sleep (medium- and high- speed) mode. 2. w clock is selected in subactive or subsleep mode. sci3 can be used only when the w /2 is selected as the cpu clock in subactive or subsleep mode. table 10-8 shows the maximum bit rate for each frequency. the values shown are for active (high-speed) mode. table 10-8 maximum bit rate for each frequency (asynchronous mode) setting osc (mhz) maximum bit rate (bit/s) n n 0.0384 * 600 0 0 2 31250 0 0 2.4576 38400 0 0 4 62500 0 0 10 156250 0 0 16 250000 0 0 note: * when smr is set up to cks1 = 0, cks0 = 1. table 10-9 shows examples of brr settings in synchronous mode. the values shown are for active (high-speed) mode.
274 table 10-9 examples of brr settings for various bit rates (synchronous mode) (1) osc 38.4 khz 2 mhz 4 mhz bit rate (bit/s) n n error n n error n n error 200 0 230 250 2 1240 300 2 0 0 500 1k 0 249 0 2.5k 0 99 0 0 199 0 5k 04900990 10k 02400490 25k 0900190 50k 040090 100k ? 4 0 250k 000010 500k 0 0 0 1m
275 table 10-9 examples of brr settings for various bit rates (synchronous mode) (2) osc 10 mhz 16 mhz bit rate (bit/s) n n error n n error 200 250 ? 1240 300 500 ? 2490 1k ? 1240 2.5k ? 490 5k 0 249 0 2 24 0 10k 0 124 0 0 199 0 25k 04900790 50k 02400390 100k ? 190 250k 040070 500k ? 3 0 1m ? 1 0 blank: cannot be set. ?: a setting can be made, but an error will result. * : continuous transmission/reception is not possible. notes: the value set in brr is given by the following equation: n= osc (8 2 2n b) ?1 where b: bit rate (bit/s) n: baud rate generator brr setting (0 n 255) osc: value of osc (hz) n: baud rate generator input clock number (n = 0, 2, or 3) (the relation between n and the clock is shown in table 10-10.)
276 table 10-10 relation between n and clock smr setting n clock cks1 cks0 0 0 0 0 w /2 * 1 / w * 2 01 2 ?16 1 0 3 ?64 1 1 notes: 1. w /2 clock is selected in active (medium- and high-speed) or sleep (medium- and high- speed) mode. 2. w clock is selected in subactive or subsleep mode. sci3 can be used only when the w /2 is selected as the cpu operation clock in subactive or subsleep mode.
277 9. clock stop register 1 (ckstpr1) bit 7654 3210 s1ckstp s31ckstp s32ckstp adckstp tgckstp tfckstp tcckstp tackstp initial value 1111 1111 read/write r/w r/w r/w r/w r/w r/w r/w r/w ckstpr1 is an 8-bit read/write register that performs module standby mode control for peripheral modules. only the bits relating to sci3 are described here. for details of the other bits, see the sections on the relevant modules. bit 6: sci31 module standby mode control (s31ckstp) bit 6 controls setting and clearing of module standby mode for sci31. s31ckstp description 0 sci31 is set to module standby mode * 1 sci31 module standby mode is cleared (initial value) note: * setting to module standby mode resets all the registers in sci31. bit 5: sci32 module standby mode control (s32ckstp) bit 5 controls setting and clearing of module standby mode for sci32. s32ckstp description 0 sci32 is set to module standby mode * 1 sci32 module standby mode is cleared (initial value) note: * setting to module standby mode resets all the registers in sci32.
278 10. serial port control register (spcr) bit initial value read/write 7 1 6 1 5 spc32 0 r/w 4 spc31 0 r/w 3 scinv3 0 r/w 0 scinv0 0 r/w 2 scinv2 0 r/w 1 scinv1 0 r/w spcr is an 8-bit readable/writable register that performs rxd 31 , rxd 32 , txd 31 , and txd 32 pin input/output data inversion switching. spcr is initialized to h'c0 by a reset. bits 7 and 6: reserved bits bits 7 and 6 are reserved; they are always read as 1 and cannot be modified. bit 5: p4 2 /txd 32 pin function switch (spc32) this bit selects whether pin p4 2 /txd 32 is used as p4 2 or as txd 32 . bit 5 spc32 description 0 functions as p4 2 i/o pin (initial value) 1 functions as txd 32 output pin * note: * set the te bit in scr3 after setting this bit to 1. bit 4: p3 5 /txd 31 pin function switch (spc31) this bit selects whether pin p3 5 /txd 31 is used as p3 5 or as txd 31 . bit 4 spc31 description 0 functions as p3 5 i/o pin (initial value) 1 functions as txd 31 output pin * note: * set the te bit in scr3 after setting this bit to 1. bit 3: txd 32 pin output data inversion switch bit 3 specifies whether or not txd 32 pin output data is to be inverted. bit 3 scinv3 description 0 txd 32 output data is not inverted (initial value) 1 txd 32 output data is inverted
279 bit 2: rxd 32 pin input data inversion switch bit 2 specifies whether or not rxd 32 pin input data is to be inverted. bit 2 scinv2 description 0 rxd 32 input data is not inverted (initial value) 1 rxd 32 input data is inverted bit 1: txd 31 pin output data inversion switch bit 1 specifies whether or not txd 31 pin output data is to be inverted. bit 1 scinv1 description 0 txd 31 output data is not inverted (initial value) 1 txd 31 output data is inverted bit 0: rxd 31 pin input data inversion switch bit 0 specifies whether or not rxd 31 pin input data is to be inverted. bit 0 scinv0 description 0 rxd 31 input data is not inverted (initial value) 1 rxd 31 input data is inverted
280 10.3.3 operation 1. overview sci3 can perform serial communication in two modes: asynchronous mode in which synchronization is provided character by character, and synchronous mode in which synchronization is provided by clock pulses. the serial mode register (smr) is used to select asynchronous or synchronous mode and the data transfer format, as shown in table 10-11. the clock source for sci3 is determined by bit com in smr and bits cke1 and cke0 in scr3, as shown in table 10-12. a. asynchronous mode ? ? ? ? ? ? ?
281 table 10-11 smr settings and corresponding data transfer formats smr data transfer format bit 7 com bit 6 chr bit 2 mp bit 5 pe bit 3 stop mode data length multiprocessor bit parity bit stop bit length 0 0 0 0 0 asynchronous 8-bit data no no 1 bit 0 0 0 0 1 mode 2 bits 0 0 0 1 0 yes 1 bit 0 0 0 1 1 2 bits 0 1 0 0 0 7-bit data no 1 bit 0 1 0 0 1 2 bits 0 1 0 1 0 yes 1 bit 0 1 0 1 1 2 bits 0 0 1 0 0 8-bit data yes no 1 bit 0 0 1 0 1 2 bits 0 0 1 1 0 5-bit data no 1 bit 0 0 1 1 1 2 bits 0 1 1 0 0 7-bit data yes 1 bit 0 1 1 0 1 2 bits 0 1 1 1 0 5-bit data no yes 1 bit 0 1 1 1 1 2 bits 1 * 0 ** synchronous mode 8-bit data no no no * : don t care
282 table 10-12 smr and scr3 settings and clock source selection smr scr3 bit 7 bit 1 bit 0 transmit/receive clock com cke1 cke0 mode clock source sck 3x pin function 0 0 0 asynchronous internal i/o port (sck 3x pin not used) 001 mode outputs clock with same frequency as bit rate 0 1 0 external outputs clock with frequency 16 times bit rate 1 0 0 synchronous internal outputs serial clock 110 mode external inputs serial clock 0 1 1 reserved (do not specify these combinations) 101 111
283 c. interrupts and continuous transmission/reception sci3 can carry out continuous reception using rxi and continuous transmission using txi. these interrupts are shown in table 10-13. table 10-13 transmit/receive interrupts interrupt flags interrupt request conditions notes rxi rdrf rie when serial reception is performed normally and receive data is transferred from rsr to rdr, bit rdrf is set to 1, and if bit rie is set to 1 at this time, rxi is enabled and an interrupt is requested. (see figure 10-4 (a).) the rxi interrupt routine reads the receive data transferred to rdr and clears bit rdrf to 0. continuous reception can be performed by repeating the above operations until reception of the next rsr data is completed. txi tdre tie when tsr is found to be empty (on completion of the previous transmission) and the transmit data placed in tdr is transferred to tsr, bit tdre is set to 1. if bit tie is set to 1 at this time, txi is enabled and an interrupt is requested. (see figure 10-4 (b).) the txi interrupt routine writes the next transmit data to tdr and clears bit tdre to 0. continuous transmission can be performed by repeating the above operations until the data transferred to tsr has been transmitted. tei tend teie when the last bit of the character in tsr is transmitted, if bit tdre is set to 1, bit tend is set to 1. if bit teie is set to 1 at this time, tei is enabled and an interrupt is requested. (see figure 10-4 (c).) tei indicates that the next transmit data has not been written to tdr when the last bit of the transmit character in tsr is sent.
284 rdr rsr (reception in progress) rdrf = 0 rxd 3x pin rdr rsr (reception completed, transfer) rdrf 1 (rxi request when rie = 1) rxd 3x pin figure 10-4 (a) rdrf setting and rxi interrupt tdr (next transmit data) tsr (transmission in progress) tdre = 0 txd 3x pin tdr tsr (transmission completed, transfer) tdre 1 (txi request when tie = 1) txd 3x pin figure 10-4 (b) tdre setting and txi interrupt tdr tsr (transmission in progress) tend = 0 txd 3x pin tdr tsr (reception completed) tend 1 (tei request when teie = 1) txd 3x pin figure 10-4 (c) tend setting and tei interrupt
285 2. operation in asynchronous mode in asynchronous mode, serial communication is performed with synchronization provided character by character. a start bit indicating the start of communication and one or two stop bits indicating the end of communication are added to each character before it is sent. sci3 has separate transmission and reception units, allowing full-duplex communication. as the transmission and reception units are both double-buffered, data can be written during transmission and read during reception, making possible continuous transmission and reception. a. data transfer format the general data transfer format in asynchronous communication is shown in figure 10-5. serial data start bit 1 bit transmit/receive data parity bit stop bit(s) 5, 7 or 8 bits one transfer data unit (character or frame) 1 bit or none 1 or 2 bits mark state 1 (msb) (lsb) figure 10-5 data format in asynchronous communication in asynchronous communication, the communication line is normally in the mark state (high level). sci3 monitors the communication line and when it detects a space (low level), identifies this as a start bit and begins serial data communication. one transfer data character consists of a start bit (low level), followed by transmit/receive data (lsb-first format, starting from the least significant bit), a parity bit (high or low level), and finally one or two stop bits (high level). in asynchronous mode, synchronization is performed by the falling edge of the start bit during reception. the data is sampled on the 8th pulse of a clock with a frequency 16 times the bit period, so that the transfer data is latched at the center of each bit. table 10-14 shows the 16 data transfer formats that can be set in asynchronous mode. the format is selected by the settings in the serial mode register (smr).
286 table 10-14 data transfer formats (asynchronous mode) 1 chr 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 pe mp stop 2 3 4 5 8-bit data serial data transfer format and frame length smr stop s 6 7 8 9 10 11 12 8-bit data s 7-bit data stop stop s stop 7-bit data s stop stop 5-bit data s stop 5-bit data s stop stop 8-bit data p s stop 8-bit data p s stop stop 8-bit data mpb s stop 8-bit data mpb s stop stop 7-bit data p stop s stop 7-bit data stop s 5-bit data stop p p p s 5-bit data stop stop s notation: s: stop: p: mpb: start bit stop bit parity bit multiprocessor bit stop 7-bit data stop s 7-bit data stop mpb mpb s
287 b. clock either an internal clock generated by the baud rate generator or an external clock input at the sck 3x pin can be selected as the sci3 transmit/receive clock. the selection is made by means of bit com in smr and bits sce1 and cke0 in scr3. see table 10-12 for details on clock source selection. when an external clock is input at the sck 3x pin, the clock frequency should be 16 times the bit rate. when sci3 operates on an internal clock, the clock can be output at the sck 3x pin. in this case the frequency of the output clock is the same as the bit rate, and the phase is such that the clock rises at the center of each bit of transmit/receive data, as shown in figure 10-6. 1 character (1 frame) 0 d0d1d2d3d4d5d6d70/1 1 1 clock serial data figure 10-6 phase relationship between output clock and transfer data (asynchronous mode) (8-bit data, parity, 2 stop bits) c. data transfer operations ?
288 figure 10-7 shows an example of a flowchart for initializing sci3. start end clear bits te and re to 0 in scr3 1 2 3 set bits cke1 and cke0 set data transfer format in smr set bits spc31 and spc32 to 1 in spcr set value in brr no wait yes 4 set bits tie, rie, mpie, and teie in scr3, and set bits re and te to 1 in pmr7 has 1-bit period elapsed? set clock selection in scr3. be sure to clear the other bits to 0. if clock output is selected in asynchronous mode, the clock is output immediately after setting bits cke1 and cke0. if clock output is selected for reception in synchronous mode, the clock is output immediately after bits cke1, cke0, and re are set to 1. set the data transfer format in the serial mode register (smr). write the value corresponding to the transfer rate in brr. this operation is not necessary when an external clock is selected. wait for at least one bit period, then set bits tie, rie, mpie, and teie in scr3, and set bits re and te to 1 in pmr7. setting bits te and re enables the txd3x and rxd3x pins to be used. in asynchronous mode the mark state is established when transmitting, and the idle state waiting for a start bit when receiving. 1. 2. 3. 4. figure 10-7 example of sci3 initialization flowchart
289 ? start end read bit tdre in ssr sets bits spc31 and spc32 to 1 in spcr 1 2 3 write transmit data to tdr read bit tend in ssr set pdr = 0, pcr = 1 clear bit te to 0 in scr3 no tdre = 1? yes continue data transmission? no tend = 1? no yes yes yes no break output? read the serial status register (ssr) and check that bit tdre is set to 1, then write transmit data to the transmit data register (tdr). when data is written to tdr, bit tdre is cleared to 0 automatically. (after the te bit is set to 1, one frame of 1s is output, then transmission is possible.) when continuing data transmission, be sure to read tdre = 1 to confirm that a write can be performed before writing data to tdr. when data is written to tdr, bit tdre is cleared to 0 automatically. if a break is to be output when data transmission ends, set the port pcr to 1 and clear the port pdr to 0, then clear bit te in scr3 to 0. 1. 2. 3. figure 10-8 example of data transmission flowchart (asynchronous mode)
290 sci3 operates as follows when transmitting data. sci3 monitors bit tdre in ssr, and when it is cleared to 0, recognizes that data has been written to tdr and transfers data from tdr to tsr. it then sets bit tdre to 1 and starts transmitting. if bit tie in scr3 is set to 1 at this time, a txi request is made. serial data is transmitted from the txd3x pin using the relevant data transfer format in table 10- 14. when the stop bit is sent, sci3 checks bit tdre. if bit tdre is cleared to 0, sci3 transfers data from tdr to tsr, and when the stop bit has been sent, starts transmission of the next frame. if bit tdre is set to 1, bit tend in ssr bit is set to 1the mark state, in which 1s are transmitted, is established after the stop bit has been sent. if bit teie in scr3 is set to 1 at this time, a tei request is made. figure 10-9 shows an example of the operation when transmitting in asynchronous mode. 1 frame start bit start bit transmit data transmit data parity bit stop bit parity bit stop bit mark state 1 frame 0 1 d0 d1 d7 0/1 1 1 1 0 d0 d1 d7 0/1 serial data tdre tend lsi operation txi request tdre cleared to 0 user processing data written to tdr txi request tei request figure 10-9 example of operation when transmitting in asynchronous mode (8-bit data, parity, 1 stop bit)
291 ? start end read bits oer, per, fer in ssr 1 2 3 4 read bit rdrf in ssr read receive data in rdr clear bit re to 0 in scr3 yes oer + per + fer = 1? no rdrf = 1? yes continue data reception? no no yes receive error processing (a) read bits oer, per, and fer in the serial status register (ssr) to determine if there is an error. if a receive error has occurred, execute receive error processing. read ssr and check that bit rdrf is set to 1. if it is, read the receive data in rdr. when the rdr data is read, bit rdrf is cleared to 0 automatically. when continuing data reception, finish reading of bit rdrf and rdr before receiving the stop bit of the current frame. when the data in rdr is read, bit rdrf is cleared to 0 automatically. 1. 2. 3. figure 10-10 example of data reception flowchart (asynchronous mode)
292 start receive error processing end of receive error processing 4 clear bits oer, per, fer to 0 in ssr yes oer = 1? yes yes fer = 1? break? yes per = 1? no no no no overrun error processing framing error processing (a) parity error processing if a receive error has occurred, read bits oer, per, and fer in ssr to identify the error, and after carrying out the necessary error processing, ensure that bits oer, per, and fer are all cleared to 0. reception cannot be resumed if any of these bits is set to 1. in the case of a framing error, a break can be detected by reading the value of the rxd 3x pin. 4. figure 10-10 example of data reception flowchart (asynchronous mode) (cont)
293 sci3 operates as follows when receiving data. sci3 monitors the communication line, and when it detects a 0 start bit, performs internal synchronization and begins reception. reception is carried out in accordance with the relevant data transfer format in table 10-14. the received data is first placed in rsr in lsb-to-msb order, and then the parity bit and stop bit(s) are received. sci3 then carries out the following checks. ? ? ? table 10-15 receive error detection conditions and receive data processing receive error abbreviation detection conditions receive data processing overrun error oer when the next date receive operation is completed while bit rdrf is still set to 1 in ssr receive data is not transferred from rsr to rdr framing error fer when the stop bit is 0 receive data is transferred from rsr to rdr parity error per when the parity (odd or even) set in smr is different from that of the received data receive data is transferred from rsr to rdr
294 figure 10-11 shows an example of the operation when receiving in asynchronous mode. 1 frame start bit start bit receive data receive data parity bit stop bit parity bit stop bit mark state (idle state) 1 frame 0 1 d0 d1 d7 0/1 1 0 1 0 d0 d1 d7 0/1 serial data rdrf fer lsi operation user processing rdrf cleared to 0 rdr data read framing error processing rxi request 0 start bit detected eri request in response to framing error figure 10-11 example of operation when receiving in asynchronous mode (8-bit data, parity, 1 stop bit) 3. operation in synchronous mode in synchronous mode, sci3 transmits and receives data in synchronization with clock pulses. this mode is suitable for high-speed serial communication. sci3 has separate transmission and reception units, allowing full-duplex communication with a shared clock. as the transmission and reception units are both double-buffered, data can be written during transmission and read during reception, making possible continuous transmission and reception.
295 a. data transfer format the general data transfer format in synchronous communication is shown in figure 10-12. serial clock serial data note: high level except in continuous transmission/reception lsb msb * * bit 1 bit 0 bit 2 bit 3 bit 4 8 bits one transfer data unit (character or frame) bit 5 bit 6 bit 7 don't care don't care figure 10-12 data format in synchronous communication in synchronous communication, data on the communication line is output from one falling edge of the serial clock until the next falling edge. data confirmation is guaranteed at the rising edge of the serial clock. one transfer data character begins with the lsb and ends with the msb. after output of the msb, the communication line retains the msb state. when receiving in synchronous mode, sci3 latches receive data at the rising edge of the serial clock. the data transfer format uses a fixed 8-bit data length. parity and multiprocessor bits cannot be added. b. clock either an internal clock generated by the baud rate generator or an external clock input at the sck3x pin can be selected as the sci3 serial clock. the selection is made by means of bit com in smr and bits cke1 and cke0 in scr3. see table 10-12 for details on clock source selection. when sci3 operates on an internal clock, the serial clock is output at the sck3x pin. eight pulses of the serial clock are output in transmission or reception of one character, and when sci3 is not transmitting or receiving, the clock is fixed at the high level.
296 c. data transfer operations ? sci initialization under 10.3.3, 2. c. data transfer operations, and shown in figure 10-7. ? start end read bit tdre in ssr sets bits spc31 and spc32 to 1 in spcr 1 2 write transmit data to tdr read bit tend in ssr clear bit te to 0 in scr3 no tdre = 1? yes continue data transmission? no tend = 1? yes yes no read the serial status register (ssr) and check that bit tdre is set to 1, then write transmit data to the transmit data register (tdr). when data is written to tdr, bit tdre is cleared to 0 automatically, the clock is output, and data transmission is started. when clock output is selected, the clock is output and data transmission started when data is written to tdr. when continuing data transmission, be sure to read tdre = 1 to confirm that a write can be performed before writing data to tdr. when data is written to tdr, bit tdre is cleared to 0 automatically. 1. 2. figure 10-13 example of data transmission flowchart (synchronous mode)
297 sci3 operates as follows when transmitting data. sci3 monitors bit tdre in ssr, and when it is cleared to 0, recognizes that data has been written to tdr and transfers data from tdr to tsr. it then sets bit tdre to 1 and starts transmitting. if bit tie in scr3 is set to 1 at this time, a txi request is made. when clock output mode is selected, sci3 outputs 8 serial clock pulses. when an external clock is selected, data is output in synchronization with the input clock. serial data is transmitted from the txd3x pin in order from the lsb (bit 0) to the msb (bit 7). when the msb (bit 7) is sent, checks bit tdre. if bit tdre is cleared to 0, sci3 transfers data from tdr to tsr, and starts transmission of the next frame. if bit tdre is set to 1, sci3 sets bit tend to 1 in ssr, and after sending the msb (bit 7), retains the msb state. if bit teie in scr3 is set to 1 at this time, a tei request is made. after transmission ends, the sck pin is fixed at the high level. note: transmission is not possible if an error flag (oer, fer, or per) that indicates the data reception status is set to 1. check that these error flags are all cleared to 0 before a transmit operation. figure 10-14 shows an example of the operation when transmitting in synchronous mode. serial clock serial data bit 1 bit 0 bit 7 bit 0 1 frame 1 frame bit 1 bit 6 bit 7 tdre tend lsi operation user processing txi request data written to tdr tdre cleared to 0 txi request tei request figure 10-14 example of operation when transmitting in synchronous mode
298 ? start end read bit oer in ssr 1 2 3 4 read bit rdrf in ssr overrun error processing 4 clear bit oer to 0 in ssr read receive data in rdr clear bit re to 0 in scr3 yes oer = 1? no rdrf = 1? yes continue data reception? no no yes overrun error processing end of overrun error processing start overrun error processing read bit oer in the serial status register (ssr) to determine if there is an error. if an overrun error has occurred, execute overrun error processing. read ssr and check that bit rdrf is set to 1. if it is, read the receive data in rdr. when the rdr data is read, bit rdrf is cleared to 0 automatically. when continuing data reception, finish reading of bit rdrf and rdr before receiving the msb (bit 7) of the current frame. when the data in rdr is read, bit rdrf is cleared to 0 automatically. if an overrun error has occurred, read bit oer in ssr, and after carrying out the necessary error processing, clear bit oer to 0. reception cannot be resumed if bit oer is set to 1. 1. 2. 3. 4. figure 10-15 example of data reception flowchart (synchronous mode)
299 sci3 operates as follows when receiving data. sci3 performs internal synchronization and begins reception in synchronization with the serial clock input or output. the received data is placed in rsr in lsb-to-msb order. after the data has been received, sci3 checks that bit rdrf is set to 0, indicating that the receive data can be transferred from rsr to rdr. if this check shows that there is no overrun error, bit rdrf is set to 1, and the receive data is stored in rdr. if bit rie is set to 1 in scr3, an rxi interrupt is requested. if the check identifies an overrun error, bit oer is set to 1. bit rdrf remains set to 1. if bit rie is set to 1 in scr3, an eri interrupt is requested. see table 10-15 for the conditions for detecting a receive error, and receive data processing. note: no further receive operations are possible while a receive error flag is set. bits oer, fer, per, and rdrf must therefore be cleared to 0 before resuming reception. figure 10-16 shows an example of the operation when receiving in synchronous mode. serial clock serial data bit 0 bit 7 bit 7 bit 0 1 frame 1 frame bit 1 bit 6 bit 7 rdrf oer lsi operation user processing rxi request rdr data read rdre cleared to 0 rxi request eri request in response to overrun error overrun error processing rdr data has not been read (rdrf = 1) figure 10-16 example of operation when receiving in synchronous mode
300 ? start end read bit tdre in ssr sets bits spc31 and spc32 to 1 in spcr 1 2 3 4 write transmit data to tdr read bit oer in ssr read bit rdrf in ssr clear bits te and re to 0 in scr3 yes tdre = 1? no oer = 1? no rdrf = 1? yes continue data transmission/reception? no yes no read receive data in rdr yes overrun error processing read the serial status register (ssr) and check that bit tdre is set to 1, then write transmit data to the transmit data register (tdr). when data is written to tdr, bit tdre is cleared to 0 automatically. read ssr and check that bit rdrf is set to 1. if it is, read the receive data in rdr. when the rdr data is read, bit rdrf is cleared to 0 automatically. when continuing data transmission/reception, finish reading of bit rdrf and rdr before receiving the msb (bit 7) of the current frame. before receiving the msb (bit 7) of the current frame, also read tdre = 1 to confirm that a write can be performed, then write data to tdr. when data is written to tdr, bit tdre is cleared to 0 automatically, and when the data in rdr is read, bit rdrf is cleared to 0 automatically. if an overrun error has occurred, read bit oer in ssr, and after carrying out the necessary error processing, clear bit oer to 0. transmis- sion and reception cannot be resumed if bit oer is set to 1. see figure 10-18 for details on overrun error processing. 1. 2. 3. 4. notes: 1. when switching from transmission to simultaneous transmission/reception, check that sci3 has finished transmitting and that bits tdre and tend are set to 1, clear bit te to 0, and then set bits te and re to 1. 2. when switching from reception to simultaneous transmission/reception, check that sci3 has finished receiving, clear bit re to 0, then check that bit rdrf and the error flags (oer, fer, and per) are cleared to 0, and finally set bits te and re to 1. figure 10-17 example of simultaneous data transmission/reception flowchart (synchronous mode)
301 4. multiprocessor communication function the multiprocessor communication function enables data to be exchanged among a number of processors on a shared communication line. serial data communication is performed in asynchronous mode using the multiprocessor format (in which a multiprocessor bit is added to the transfer data). in multiprocessor communication, each receiver is assigned its own id code. the serial communication cycle consists of two cycles, an id transmission cycle in which the receiver is specified, and a data transmission cycle in which the transfer data is sent to the specified receiver. these two cycles are differentiated by means of the multiprocessor bit, 1 indicating an id transmission cycle, and 0, a data transmission cycle. the sender first sends transfer data with a 1 multiprocessor bit added to the id code of the receiver it wants to communicate with, and then sends transfer data with a 0 multiprocessor bit added to the transmit data. when a receiver receives transfer data with the multiprocessor bit set to 1, it compares the id code with its own id code, and if they are the same, receives the transfer data sent next. if the id codes do not match, it skips the transfer data until data with the multiprocessor bit set to 1 is sent again. in this way, a number of processors can exchange data among themselves. figure 10-18 shows an example of communication between processors using the multiprocessor format.
302 sender serial data receiver a (id = 01) (id = 02) receiver b h'01 id transmission cycle (specifying the receiver) data transmission cycle (sending data to the receiver specified buy the id) mpb: multiprocessor bit (mpb = 1) (mpb = 0) h'aa communication line (id = 03) receiver c (id = 04) receiver d figure 10-18 example of inter-processor communication using multiprocessor format (sending data h'aa to receiver a) there is a choice of four data transfer formats. if a multiprocessor format is specified, the parity bit specification is invalid. see table 10-14 for details. for details on the clock used in multiprocessor communication, see 10.3.3, 2. operation in asynchronous mode. ?
303 start end read bit tdre in ssr sets bits spc31 and spc32 to 1 in spcr 1 3 2 set bit mpdt in ssr write transmit data to tdr read bit tend in ssr clear bit te to 0 in scr3 set pdr = 0, pcr = 1 yes tdre = 1? no continue data transmission? no tend = 1? break output? no yes yes no yes read the serial status register (ssr) and check that bit tdre is set to 1, then set bit mpbt in ssr to 0 or 1 and write transmit data to the transmit data register (tdr). when data is written to tdr, bit tdre is cleared to 0 automatically. when continuing data transmission, be sure to read tdre = 1 to confirm that a write can be performed before writing data to tdr. when data is written to tdr, bit tdre is cleared to 0 automatically. if a break is to be output when data transmission ends, set the port pcr to 1 and clear the port pdr to 0, then clear bit te in scr3 to 0. 1. 2. 3. figure 10-19 example of multiprocessor data transmission flowchart
304 sci3 operates as follows when transmitting data. sci3 monitors bit tdre in ssr, and when it is cleared to 0, recognizes that data has been written to tdr and transfers data from tdr to tsr. it then sets bit tdre to 1 and starts transmitting. if bit tie in scr3 is set to 1 at this time, a txi request is made. serial data is transmitted from the txd pin using the relevant data transfer format in table 10-14. when the stop bit is sent, sci3 checks bit tdre. if bit tdre is cleared to 0, sci3 transfers data from tdr to tsr, and when the stop bit has been sent, starts transmission of the next frame. if bit tdre is set to 1 bit tend in ssr bit is set to 1, the mark state, in which 1s are transmitted, is established after the stop bit has been sent. if bit teie in scr3 is set to 1 at this time, a tei request is made. figure 10-20 shows an example of the operation when transmitting using the multiprocessor format. 1 frame start bit start bit transmit data transmit data mpb mpb stop bit stop bit mark state 1 frame 0 1 d0 d1 d7 0/1 1 1 1 0 d0 d1 d7 0/1 serial data tdre tend lsi operation txi request tdre cleared to 0 user processing data written to tdr txi request tei request figure 10-20 example of operation when transmitting using multiprocessor format (8-bit data, multiprocessor bit, 1 stop bit) ?
305 start end read bits oer and fer in ssr 2 set bit mpie to 1 in scr3 1 3 4 5 4 read bit rdrf in ssr read receive data in rdr clear bit re to 0 in scr3 yes oer + fer = 1? no rdrf = 1? yes continue data reception? no no yes read bits oer and fer in ssr no own id? yes read bit rdrf in ssr yes oer + fer = 1? no read receive data in rdr no rdrf = 1? yes receive error processing (a) set bit mpie to 1 in scr3. read bits oer and fer in the serial status register (ssr) to determine if there is an error. if a receive error has occurred, execute receive error processing. read ssr and check that bit rdrf is set to 1. if it is, read the receive data in rdr and compare it with this receiver's own id. if the id is not this receiver's, set bit mpie to 1 again. when the rdr data is read, bit rdrf is cleared to 0 automatically. read ssr and check that bit rdrf is set to 1, then read the data in rdr. if a receive error has occurred, read bits oer and fer in ssr to identify the error, and after carrying out the necessary error processing, ensure that bits oer and fer are both cleared to 0. reception cannot be resumed if either of these bits is set to 1. in the case of a framing error, a break can be detected by reading the value of the rxd 3x pin. 1. 2. 3. 4. 5. figure 10-21 example of multiprocessor data reception flowchart
306 start receive error processing end of receive error processing clear bits oer and fer to 0 in ssr yes oer = 1? yes yes fer = 1? break? no no no overrun error processing framing error processing (a) figure 10-21 example of multiprocessor data reception flowchart (cont) figure 10-22 shows an example of the operation when receiving using the multiprocessor format.
307 1 frame start bit start bit receive data (id1) receive data (data1) mpb mpb stop bit stop bit mark state (idle state) 1 frame 0 1d0d1d711 11 0d0d1 d7 id1 0 serial data mpie rdrf rdr value rdr value lsi operation rxi request mpie cleared to 0 user processing rdrf cleared to 0 no rxi request rdr retains previous state rdr data read when data is not this receiver's id, bit mpie is set to 1 again 1 frame start bit start bit receive data (id2) receive data (data2) mpb mpb stop bit stop bit mark state (idle state) 1 frame 0 1d0d1d711 11 0 (a) when data does not match this receiver's id (b) when data matches this receiver's id d0 d1 d7 id2 data2 id1 0 serial data mpie rdrf lsi operation rxi request mpie cleared to 0 user processing rdrf cleared to 0 rxi request rdrf cleared to 0 rdr data read when data is this receiver's id, reception is continued rdr data read bit mpie set to 1 again figure 10-22 example of operation when receiving using multiprocessor format (8-bit data, multiprocessor bit, 1 stop bit)
308 10.3.4 interrupts sci3 can generate six kinds of interrupts: transmit end, transmit data empty, receive data full, and three receive error interrupts (overrun error, framing error, and parity error). these interrupts have the same vector address. the various interrupt requests are shown in table 10-16. table 10-16 sci3 interrupt requests interrupt abbreviation interrupt request vector address rxi interrupt request initiated by receive data full flag (rdrf) h'0022/h'0024 txi interrupt request initiated by transmit data empty flag (tdre) tei interrupt request initiated by transmit end flag (tend) eri interrupt request initiated by receive error flag (oer, fer, per) each interrupt request can be enabled or disabled by means of bits tie and rie in scr3. when bit tdre is set to 1 in ssr, a txi interrupt is requested. when bit tend is set to 1 in ssr, a tei interrupt is requested. these two interrupts are generated during transmission. the initial value of bit tdre in ssr is 1. therefore, if the transmit data empty interrupt request (txi) is enabled by setting bit tie to 1 in scr3 before transmit data is transferred to tdr, a txi interrupt will be requested even if the transmit data is not ready. also, the initial value of bit tend in ssr is 1. therefore, if the transmit end interrupt request (tei) is enabled by setting bit teie to 1 in scr3 before transmit data is transferred to tdr, a tei interrupt will be requested even if the transmit data has not been sent. effective use of these interrupt requests can be made by having processing that transfers transmit data to tdr carried out in the interrupt service routine. to prevent the generation of these interrupt requests (txi and tei), on the other hand, the enable bits for these interrupt requests (bits tie and teie) should be set to 1 after transmit data has been transferred to tdr. when bit rdrf is set to 1 in ssr, an rxi interrupt is requested, and if any of bits oer, per, and fer is set to 1, an eri interrupt is requested. these two interrupt requests are generated during reception. for further details, see 3.3, interrupts.
309 10.3.5 application notes the following points should be noted when using sci3. 1. relation between writes to tdr and bit tdre bit tdre in the serial status register (ssr) is a status flag that indicates that data for serial transmission has not been prepared in tdr. when data is written to tdr, bit tdre is cleared to 0 automatically. when sci3 transfers data from tdr to tsr, bit tdre is set to 1. data can be written to tdr irrespective of the state of bit tdre, but if new data is written to tdr while bit tdre is cleared to 0, the data previously stored in tdr will be lost of it has not yet been transferred to tsr. accordingly, to ensure that serial transmission is performed dependably, you should first check that bit tdre is set to 1, then write the transmit data to tdr once only (not two or more times). 2. operation when a number of receive errors occur simultaneously if a number of receive errors are detected simultaneously, the status flags in ssr will be set to the states shown in table 10-17. if an overrun error is detected, data transfer from rsr to rdr will not be performed, and the receive data will be lost. table 10-17 ssr status flag states and receive data transfer ssr status flags receive data transfer rdrf * oer fer per rsr 1100 overrun error 0010 ? framing error 0001 ? parity error 1110 overrun error + framing error 1101 overrun error + parity error 0011 ? framing error + parity error 1111 overrun error + framing error + parity error ? : receive data is transferred from rsr to rdr. : receive data is not transferred from rsr to rdr. note: * bit rdrf retains its state prior to data reception. however, note that if rdr is read after an overrun error has occurred in a frame because reading of the receive data in the previous frame was delayed, rdrf will be cleared to 0.
310 3. break detection and processing when a framing error is detected, a break can be detected by reading the value of the rxd 3x pin directly. in a break, the input from the rxd 3x pin becomes all 0s, with the result that bit fer is set and bit per may also be set. sci3 continues the receive operation even after receiving a break. note, therefore, that even though bit fer is cleared to 0 it will be set to 1 again. 4. mark state and break detection when bit te is cleared to 0, the txd 3x pin functions as an i/o port whose input/output direction and level are determined by pdr and pcr. this fact can be used to set the txd 3x pin to the mark state, or to detect a break during transmission. to keep the communication line in the mark state (1 state) until bit te is set to 1, set pcr = 1 and pdr = 1. since bit te is cleared to 0 at this time, the txd 3x pin functions as an i/o port and 1 is output. to detect a break, clear bit te to 0 after setting pcr = 1 and pdr = 0. when bit te is cleared to 0, the transmission unit is initialized regardless of the current transmission state, the txd 3x pin functions as an i/o port, and 0 is output from the txd 3x pin. 5. receive error flags and transmit operation (synchronous mode only) when a receive error flag (oer, per, or fer) is set to 1, transmission cannot be started even if bit tdre is cleared to 0. the receive error flags must be cleared to 0 before starting transmission. note also that receive error flags cannot be cleared to 0 even if bit re is cleared to 0. 6. receive data sampling timing and receive margin in asynchronous mode in asynchronous mode, sci3 operates on a basic clock with a frequency 16 times the transfer rate. when receiving, sci3 performs internal synchronization by sampling the falling edge of the start bit with the basic clock. receive data is latched internally at the 8th rising edge of the basic clock. this is illustrated in figure 10-23.
311 0 7 15 0 7 15 0 internal basic clock receive data (rxd3x) start bit d0 16 clock pulses 8 clock pulses d1 synchronization sampling timing data sampling timing figure 10-23 receive data sampling timing in asynchronous mode consequently, the receive margin in asynchronous mode can be expressed as shown in equation (1). m ={(0.5 1 2n ) d 0.5 n (l 0.5) f} 5 100 [%] ..... equation (1) where m: receive margin (%) n: ratio of bit rate to clock (n = 16) d: clock duty (d = 0.5 to 1.0) l: frame length (l = 9 to 12) f: absolute value of clock frequency deviation substituting 0 for f (absolute value of clock frequency deviation) and 0.5 for d (clock duty) in equation (1), a receive margin of 46.875% is given by equation (2). when d = 0.5 and f = 0, m = {0.5 1/(2
312 7. relation between rdr reads and bit rdrf in a receive operation, sci3 continually checks the rdrf flag. if bit rdrf is cleared to 0 when reception of one frame ends, normal data reception is completed. if bit rdrf is set to 1, this indicates that an overrun error has occurred. when the contents of rdr are read, bit rdrf is cleared to 0 automatically. therefore, if bit rdr is read more than once, the second and subsequent read operations will be performed while bit rdrf is cleared to 0. note that, when an rdr read is performed while bit rdrf is cleared to 0, if the read operation coincides with completion of reception of a frame, the next frame of data may be read. this is illustrated in figure 10-24. communication line rdrf rdr frame 1 frame 2 frame 3 data 1 data 1 rdr read rdr read data 1 is read at point (a) data 2 data 3 data 2 (a) data 2 is read at point (b) (b) figure 10-24 relation between rdr read timing and data in this case, only a single rdr read operation (not two or more) should be performed after first checking that bit rdrf is set to 1. if two or more reads are performed, the data read the first time should be transferred to ram, etc., and the ram contents used. also, ensure that there is sufficient margin in an rdr read operation before reception of the next frame is completed. to be precise in terms of timing, the rdr read should be completed before bit 7 is transferred in synchronous mode, or before the stop bit is transferred in asynchronous mode. 8. transmission and reception operation at state transition make sure state transition operation is performed after transmission and reception operations are completed.
313 9. cautions on switching of sck 3x pin function if the function of the sck 3x pin is switched from clock output to i/o port after using the sci3 in clock synchronization mode, the low level is output in a moment (1/2 of the system clock ) at the sck 3x pin function switching. this momentary low level output can be avoided in either of the following two methods: a. when disabling sck 3x pin clock output when stopping signal transmission, clear the bits te and re in scr3, and set the cke1 bit to 1 and the cke0 bit to 0 simultaneously with a single command. in this case, use the com bit in smr set at 1. this means it cannot be used as an i/o port. also, to avoid intermediate potential from being applied to the sck 3x pin, pull up the line connected to the sck 3x pin to v cc potential with a resistance, or supply an output from other devices. b. when switching the sck 3x pin function from clock output to i/o port when stopping signal transmission, (1) clear the bits te and re in scr3, and set the cke1 bit to 1 and the cke0 bit to 0 simultaneously with a single command. (2) then, clear the com bit in smr to 0. (3) finally, clear the bits cke1 and cke0 in scr3 to 0. avoid intermediate potential from being applied to the sck 3x pin. 10. setting in subactive and subsleep modes in subactive or subsleep mode, sci3 can be used only when the w /2 is selected as the cpu clock. set the sa1 bit in syscr2 to 1.
314
315 section 11 a/d converter 11.1 overview the h8/3937 series and h8/3937r series include on-chip a resistance-ladder-based successive- approximation analog-to-digital converter, and can convert up to 8 channels of analog input. 11.1.1 features the a/d converter has the following features. ? 10-bit resolution ? 8 input channels ? conversion time: approx. 12.4 ? per channel (at 5 mhz operation) ? built-in sample-and-hold function ? interrupt requested on completion of a/d conversion ? a/d conversion can be started by external trigger input ? use of module standby mode enables this module to be placed in standby mode independently when not used.
316 11.1.2 block diagram figure 11-1 shows a block diagram of the a/d converter. internal data bus amr adsr adrrh adrrl control logic + com- parator an an an an an an an an adtrg av av cc ss multiplexer reference voltage irrad av cc av ss 0 1 2 3 4 5 6 7 notation: amr: adsr: adrr: irrad: a/d mode register a/d start register a/d result register a/d conversion end interrupt request flag figure 11-1 block diagram of the a/d converter
317 11.1.3 pin configuration table 11-1 shows the a/d converter pin configuration. table 11-1 pin configuration name abbrev. i/o function analog power supply av cc input power supply and reference voltage of analog part analog ground av ss input ground and reference voltage of analog part analog input 0 an 0 input analog input channel 0 analog input 1 an 1 input analog input channel 1 analog input 2 an 2 input analog input channel 2 analog input 3 an 3 input analog input channel 3 analog input 4 an 4 input analog input channel 4 analog input 5 an 5 input analog input channel 5 analog input 6 an 6 input analog input channel 6 analog input 7 an 7 input analog input channel 7 external trigger input adtrg input external trigger input for starting a/d conversion 11.1.4 register configuration table 11-2 shows the a/d converter register configuration. table 11-2 register configuration name abbrev. r/w initial value address a/d mode register amr r/w h'30 h'ffc6 a/d start register adsr r/w h'7f h'ffc7 a/d result register h adrrh r not fixed h'ffc4 a/d result register l adrrl r not fixed h'ffc5 clock stop register 1 ckstprt1 r/w h'ff h'fffa
318 11.2 register descriptions 11.2.1 a/d result registers (adrrh, adrrl) bit initial value read/write adr9 adr4 adr3 adr2 adr8 adr7 adr6 adr5 76543210 not fixed not fixed not fixed not fixed not fixed not fixed not fixed not fixed not fixed not fixed r rrr rrr r adr1 adr0 76543210 r r adrrh adrrl adrrh and adrrl together comprise a 16-bit read-only register for holding the results of analog-to-digital conversion. the upper 8 bits of the data are held in adrrh, and the lower 2 bits in adrrl. adrrh and adrrl can be read by the cpu at any time, but the adrrh and adrrl values during a/d conversion are not fixed. after a/d conversion is complete, the conversion result is stored as 10-bit data, and this data is held until the next conversion operation starts. adrrh and adrrl are not cleared on reset. 11.2.2 a/d mode register (amr) bit initial value read/write 7 cks 0 r/w 6 trge 0 r/w 5 1 4 1 3 ch3 0 r/w 0 ch0 0 r/w 2 ch2 0 r/w 1 ch1 0 r/w amr is an 8-bit read/write register for specifying the a/d conversion speed, external trigger option, and the analog input pins. upon reset, amr is initialized to h'30.
319 bit 7: clock select (cks) bit 7 sets the a/d conversion speed. bit 7 conversion time cks conversion period ?= 1 mhz ?= 5 mhz 0 62/ (initial value) 62 ? 12.4 ? 1 31/ 31 ? note: * operation is not guaranteed if the conversion time is less than 12.4 ?. set bit 7 for a value of at least 12.4 ?. bit 6: external trigger select (trge) bit 6 enables or disables the start of a/d conversion by external trigger input. bit 6 trge description 0 disables start of a/d conversion by external trigger (initial value) 1 enables start of a/d conversion by rising or falling edge of external trigger at pin adtrg * note: * the external trigger ( adtrg bits 5 and 4: reserved bits bits 5 and 4 are reserved; they are always read as 1, and cannot be modified.
320 bits 3 to 0: channel select (ch3 to ch0) bits 3 to 0 select the analog input channel. the channel selection should be made while bit adsf is cleared to 0. bit 3 ch3 bit 2 ch2 bit 1 ch1 bit 0 ch0 analog input channel 00 ** no channel selected (initial value) 0100an 0 0101an 1 0110an 2 0111an 3 1000an 4 1001an 5 1010an 6 1011an 7 11 ** reserved * : don t care 11.2.3 a/d start register (adsr) bit initial value read/write 7 adsf 0 r/w 6 1 5 1 4 1 3 1 0 1 2 1 1 1 the a/d start register (adsr) is an 8-bit read/write register for starting and stopping a/d conversion. a/d conversion is started by writing 1 to the a/d start flag (adsf) or by input of the designated edge of the external trigger signal, which also sets adsf to 1. when conversion is complete, the converted data is set in adrrh and adrrl, and at the same time adsf is cleared to 0.
321 bit 7: a/d start flag (adsf) bit 7 controls and indicates the start and end of a/d conversion. bit 7 adsf description 0 read: indicates the completion of a/d conversion (initial value) write: stops a/d conversion 1 read: indicates a/d conversion in progress write: starts a/d conversion bits 6 to 0: reserved bits bits 6 to 0 are reserved; they are always read as 1, and cannot be modified. 11.2.4 clock stop register 1 (ckstpr1) s1ckstp tfckstp tcckstp tackstp s31ckstp s32ckstp adckstp tgckstp 76543210 1 1111111 r/w r/w r/w r/w r/w r/w r/w r/w bit initial value read/write ckstpr1 is an 8-bit read/write register that performs module standby mode control for peripheral modules. only the bit relating to the a/d converter is described here. for details of the other bits, see the sections on the relevant modules. bit 4: a/d converter module standby mode control (adckstp) bit 4 controls setting and clearing of module standby mode for the a/d converter. adckstp description 0 a/d converter is set to module standby mode 1 a/d converter module standby mode is cleared (initial value)
322 11.3 operation 11.3.1 a/d conversion operation the a/d converter operates by successive approximations, and yields its conversion result as 10- bit data. a/d conversion begins when software sets the a/d start flag (bit adsf) to 1. bit adsf keeps a value of 1 during a/d conversion, and is cleared to 0 automatically when conversion is complete. the completion of conversion also sets bit irrad in interrupt request register 2 (irr2) to 1. an a/d conversion end interrupt is requested if bit ienad in interrupt enable register 2 (ienr2) is set to 1. if the conversion time or input channel needs to be changed in the a/d mode register (amr) during a/d conversion, bit adsf should first be cleared to 0, stopping the conversion operation, in order to avoid malfunction. 11.3.2 start of a/d conversion by external trigger input the a/d converter can be made to start a/d conversion by input of an external trigger signal. external trigger input is enabled at pin adtrg when bit irq4 in pmr1 is set to 1 and bit trge in amr is set to 1. then when the input signal edge designated in bit ieg4 of interrupt edge select register (iegr) is detected at pin adtrg , bit adsf in adsr will be set to 1, starting a/d conversion. figure 11-2 shows the timing. pin adtrg (when bit ieg4 = 0) adsf a/d conversion figure 11-2 external trigger input timing
323 11.3.3 a/d converter operation modes a/d converter operation modes are shown in table 11-3. table 11-3 a/d converter operation modes operation mode reset active sleep watch subactive subsleep standby module standby amr reset functions functions held held held held held adsr reset functions functions held held held held held adrrh held * functions functions held held held held held adrrl held * functions functions held held held held held note: * undefined in a power-on reset. 11.4 interrupts when a/d conversion ends (adsf changes from 1 to 0), bit irrad in interrupt request register 2 (irr2) is set to 1. a/d conversion end interrupts can be enabled or disabled by means of bit ienad in interrupt enable register 2 (ienr2). for further details see 3.3, interrupts. 11.5 typical use an example of how the a/d converter can be used is given below, using channel 1 (pin an1) as the analog input channel. figure 11-3 shows the operation timing. 1. bits ch3 to ch0 of the a/d mode register (amr) are set to 0101, making pin an1 the analog input channel. a/d interrupts are enabled by setting bit ienad to 1, and a/d conversion is started by setting bit adsf to 1. 2. when a/d conversion is complete, bit irrad is set to 1, and the a/d conversion result is stored is stored in adrrh and adrrl. at the same time adsf is cleared to 0, and the a/d converter goes to the idle state. 3. bit ienad = 1, so an a/d conversion end interrupt is requested. 4. the a/d interrupt handling routine starts. 5. the a/d conversion result is read and processed.
324 6. the a/d interrupt handling routine ends. if adsf is set to 1 again afterward, a/d conversion starts and steps 2 through 6 take place. figures 11-4 and 11-5 show flow charts of procedures for using the a/d converter. idle a/d conversion (1) idle a/d conversion (2) idle interrupt (irrad) ienad adsf channel 1 (an 1 ) operation state adrrh adrrl set * set * set * read conversion result read conversion result a/d conversion result (1) a/d conversion result (2) a/d conversion starts note: ( ) indicates instruction execution by software. * figure 11-3 typical a/d converter operation timing
325 start set a/d conversion speed and input channel perform a/d conversion? end yes no disable a/d conversion end interrupt start a/d conversion adsf = 0? no yes read adsr read adrrh/adrrl data figure 11-4 flow chart of procedure for using a/d converter (polling by software)
326 start set a/d conversion speed and input channels enable a/d conversion end interrupt start a/d conversion a/d conversion end interrupt? yes no end yes no clear bit irrad to 0 in irr2 read adrrh/adrrl data perform a/d conversion? figure 11-5 flow chart of procedure for using a/d converter (interrupts used)
327 11.6 application notes ? data in adrrh and adrrl should be read only when the a/d start flag (adsf) in the a/d start register (adsr) is cleared to 0. ? changing the digital input signal at an adjacent pin during a/d conversion may adversely affect conversion accuracy. ? when a/d conversion is started after clearing module standby mode, wait for 10 ?clock cycles before starting. ? in active mode and sleep mode, the analog power supply current (ai stop1 ) flows in the ladder resistance even when the a/d converter is on standby. therefore, if the a/d converter is not used, it is recommended that av cc be connected to the system power supply and the adckstp (a/d converter module standby mode control) bit be cleared to 0 in clock stop register 1 (ckstpr1).
328
329 section 12 flex tm roaming decoder ii the contents of this section apply to the flex roaming decoder. note that underlining in the text indicates differences in specification from the flex non-roaming decoder. 12.1 overview its primary function is to process information received and demodulated from a flex radio paging channel, select messages addressed to the paging device and communicate the message information to the host. the flex decoder also operates the paging receiver in an efficient power consumption mode and enables the host to operate in a low power mode when monitoring a single channel for message information. 12.1.1 features ? flex tm paging protocol decoder ? 16 programmable user address words ? 16 fixed temporary addresses ? 16 operator messaging addresses ? 1600, 3200, and 6400 bits per second decoding ? any-phase or single-phase decoding ? uses standard serial peripheral interface (spi) in slave mode ? allows low current stop mode operation of host processor ? highly programmable receiver control ? real time clock time base ? flex fragmentation and group messaging support ? real time clock over-the-air update support ? compatible with synthesized receivers ? ssid and nid roaming support ? low battery indication (external detector) ? backward compatible to the standard and roaming flex decoders ? internal demodulator and data slicer ? improved battery savings via partial correlation and intermittent receiver clock ? full support for revision 1.9 of the flex protocol additional support: flex system software from motorola is a family of software components for building world-class products incorporating messaging capabilities. flexstack software is specifically designed to support the flex tm roaming decoder ii ic. flexstack software runs on a product? host processor and takes care of communicating with the flex decoder , acquiring
330 the proper flex channel, and fully interpreting the code words that are passed to the host from the flex decoder. additional information: additional information on the flex tm protocol decoder chip set and flexstack software can be found at the following website: http://www.hitachi.co.jp/sicd/english/products/micom/stack/stack.html. 12.1.2 system block diagram receiver low battery detector this lsi user interface synthesizer programming control receiver control 38.4 or 40 khz clock 160 khz oscillator s0/ifin lobat figure 12-1 example block diagram using internal demodulator when configured to use the internal demodulator, the flex decoder connects to a receiver capable of generating a limited (i.e. 1-bit digitized) 455 khz or 140 khz if signal. in this mode, the flex decoder has 7 receiver control lines used for warming up and shutting down a receiver in stages. the flex decoder has the ability to detect a low battery signal during the receiver control sequences. it interfaces to a host mcu through a standard spi. it has a 1 minute timer that offers low power support for a time of day function on the host. when using the internal demodulator, the oscillator frequency (or external clock) must be 160 khz. the clkout signal can be programmed to be either a 38.4 khz signal created by fractionally dividing the oscillator clock, or a 40 khz signal creating by dividing the oscillator clock by 4.
331 receiver low battery detector audio to digital convertor this lsi user interface synthesizer programming control receiver control 38.4 clock 76.8 khz oscillator audio exts1 exts0 lobat figure 12-2 example block diagram using external demodulator the flex decoder can also be configured to connect to a receiver capable of converting a 4 level audio signal into a 2 bit digital signal. in this mode, the flex decoder has 8 receiver control lines used for warming up and shutting down a receiver in stages. it also includes configuration settings for the two post detection filter bandwidths required to decode the two symbol rates of the flex signal. also when using an external demodulator, the oscillator (or external clock) must be 76.8 khz and the clkout signal (when enabled) is 38.4 khz clock output capable of driving other devices.
332 12.1.3 functional block diagram s1-s7 s1-s7 s0/ifin s0 ifin spi 4 7 ready lobat reset testd 76.8 khz or 160 khz oscillator clock generator receiver control demodulator & data slicer symbol sync sync correlator de-interleaver address comparator/ correlator error corrector noise detector local message filter spi buffer spi control/status registers external control unit internal control unit exts0 exts1 symclk dec clkout figure 12-3 block diagram
333 12.2 spi packets all data communicated between the flex decoder and the host mcu is transmitted on the spi in 32-bit packets. each packet consists of an 8-bit id followed by 24 bits of information. the flex decoder uses the spi bus in full duplex mode. in other words, whenever a packet communication occurs, the data in both directions is valid packet data. the spi interface consists of a ready pin and four spi pins ( ss , sck, mosi, and miso).the ss is used as a chip select for the flex decoder. the sck is a clock supplied by the host mcu. the data from the host is transmitted on the mosi line. the data from the flex decoder is transmitted on the miso line. timing requirements for spi communication are specified in 12.6.1, spi timing. 12.2.1 packet communication initiated by the host refer to figure 12-4. when the host sends a packet to the flex decoder, it performs the following steps: 1. select the flex decoder by driving the ss pin low. 2. wait for the flex decoder to drive the ready pin low. 3. send the 32-bit packet. 4. de-select the flex decoder by driving the ss pin high. 5. repeat steps 1 through 4 for each additional packet. high impedance state ss ready figure 12-4 typical multiple packet communications initiated by the host when the host sends a packet, it will also receive a valid packet from the flex decoder. if the flex decoder is enabled (see 12.3.1, checksum packet for a definition of enabled) and has no other packets waiting to be sent, the flex decoder will send a status packet.
334 the host must transition the ss pin from high to low to begin each 32-bit packet. the flex decoder must see a negative transition on the ss pin in order for the host to initiate each packet communication. 12.2.2 packet communication initiated by the flex decoder refer to figure 12-5.when the flex decoder has a packet for the host to read, the following occurs: 1. the flex decoder drives the ready pin low. 2. if the flex decoder is not already selected, the host selects the flex decoder by driving the ss pin low. 3. the host receives (and sends) a 32-bit packet. 4. the host de-selects the flex decoder by driving the ss pin high (optional). ss ready figure 12-5 typical multiple packet communications initiated by the flex decoder when the host is reading a packet from the flex decoder, it must send a valid packet to the flex decoder. if the host has no data to send, it is suggested that the host send a checksum packet with all of the data bits set to 0 in order to avoid disabling the flex decoder. see 12.3.1, checksum packet for more details on enabling and disabling the flex decoder. the following figure illustrates that it is not necessary to de-select the flex decoder between packets when the packets are initiated by the flex decoder.
335 ss ready figure 12-6 multiple packet communications initiated by the flex decoder with no de-select
336 12.2.3 host-to-decoder packet map the upper 8 bits of a packet comprise the packet id. the following table describes the packet id? for all of the packets that can be sent to the flex decoder from the host. table 12-1 host-to-decoder packet id map packet id (hexadecimal) packet type 00 checksum 01 configuration 02 control 03 all frame mode 04 operator message address enables 05 roaming control packet 06 timing control packet 07 - 0e reserved (host should never send) 0f receiver line control 10 receiver control configuration (off setting) 11 receiver control configuration (warm up 1 setting) 12 receiver control configuration (warm up 2 setting) 13 receiver control configuration (warm up 3 setting) 14 receiver control configuration (warm up 4 setting) 15 receiver control configuration (warm up 5 setting) 16 receiver control configuration (3200sps sync setting) 17 receiver control configuration (1600sps sync setting) 18 receiver control configuration (3200sps data setting) 19 receiver control configuration (1600sps data setting) 1a receiver control configuration (shut down 1 setting) 1b receiver control configuration (shut down 2 setting) 1c - 1f special (ignored by flex decoder) 20 frame assignment (frames 112 through 127) 21 frame assignment (frames 96 through 111) 22 frame assignment (frames 80 through 95) 23 frame assignment (frames 64 through 79) 24 frame assignment (frames 48 through 63)
337 packet id (hexadecimal) packet type 25 frame assignment (frames 32 through 47) 26 frame assignment (frames 16 through 31) 27 frame assignment (frames 0 through 15) 28 - 77 reserved (host should never send) 78 user address enable 79 - 7f reserved (host should never send) 80 user address assignment (user address 0) 81 user address assignment (user address 1) 82 user address assignment (user address 2) 83 user address assignment (user address 3) 84 user address assignment (user address 4) 85 user address assignment (user address 5) 86 user address assignment (user address 6) 87 user address assignment (user address 7) 88 user address assignment (user address 8) 89 user address assignment (user address 9) 8a user address assignment (user address 10) 8b user address assignment (user address 11) 8c user address assignment (user address 12) 8d user address assignment (user address 13) 8e user address assignment (user address 14) 8f user address assignment (user address 15) 90 - ff reserved (host should never send)
338 12.2.4 decoder-to-host packet map the following table describes the packet id? for all of the packets that can be sent to the host from the flex decoder. table 12-2 decoder-to-host packet id map packet id (hexadecimal) packet type 00 block information word 01 address 02- 57 vector or message (id is word number in frame) 58 - 5f reserved 60 roaming status packet 61 - 7d reserved 7e receiver shutdown 7f status 80 - fe reserved ff part id 12.3 host-to-decoder packet descriptions the following sections describe the packets of information sent from the host to the flex decoder. in all cases the packets should be sent msb first (bit 7 of byte 3 = bit 31 of the packet = msb). 12.3.1 checksum packet the checksum packet is used to insure proper communication between the host and the flex decoder. the flex decoder exclusive-or? the 24 data bits of every packet it receives (except the checksum packet and the special packet id? 1c through 1f hexadecimal) with an internal checksum register. upon reset and whenever the host writes a packet to the flex decoder, the flex decoder is disabled from sending any information to the host processor until the host processor sends a checksum packet with the proper checksum value (cv) to the flex decoder. when the flex decoder is disabled in this way, it prompts the host to read the part id packet. note that all other operation continues normally when the flex decoder is ?isabled? disabled only implies that data cannot be read, all other internal operations continue to function. when the flex decoder is reset, it is disabled and the internal checksum register is initialized to the 24 bit part id defined in the part id packet. see 12.4.8, part id packet for a description of the part id. every time a packet other than the checksum packet and the special packets 1c through
339 1f is sent to the decoder ic, the value sent in the 24 information bits is exclusive-or?d with the internal checksum register, the result is stored back to the checksum register, and the flex decoder is disabled. if a checksum packet is sent and the cv bits match the bits in the checksum register, the flex decoder is enabled. if a checksum packet is sent when the flex decoder is already enabled, the packet is ignored by the flex decoder. if a packet other than the checksum packet is sent when the flex decoder is enabled, the decoder ic will be disabled until a checksum packet is sent with the correct cv bits. when the host reads a packet out of the flex decoder but has no data to send, the checksum packet should be sent so the flex decoder will not be disabled. the data in the checksum packet could be a null packet (32 bit stream of all zeros) since a checksum packet will not disable the flex decoder. when the host re-configures the flex decoder, the flex decoder will be disabled from sending any packets other than the part id packet until the flex decoder is enabled with a checksum packet having the proper data. the id of the checksum packet is 0. table 12-3 checksum packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 0 0 00000 byte 2 cv 23 cv 22 cv 21 cv 20 cv 19 cv 18 cv 17 cv 16 byte 1 cv 15 cv 14 cv 13 cv 12 cv 11 cv 10 cv 9 cv 8 byte 0 cv 7 cv 6 cv 5 cv 4 cv 3 cv 2 cv 1 cv 0 cv: checksum value.
340 reset decoder disables itself decoder disables itself decoder initializes checksum register to part id value decoder initiates part id packet decoder waits for spi packet from host yes yes yes no no no packet data matches checksum register data? decoder enables itself decoder sets checksum register to the xor of the packet data bits with the checksum register bits checksum packet? decoder enabled? figure 12-7 flex decoder checksum flow chart
341 12.3.2 configuration packet the configuration packet defines a number of different configuration options for the flex decoder. proper operation is not guaranteed if these settings are changed when decoding is enabled (i.e. the on bit in the control packet is set). the id of the configuration packet is 1. table 12-4 configuration packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 0 0 00001 byte 2 0 dfc 0 0 0 ide ofd 1 ofd 0 byte 1 0 0 0 0 0 pce sp 1 sp 0 byte 0 sme mot cod mte lbp ico 0 0 dfc: disable fractional clock. when this bit is set and ide is set, the clkout signal will generate a 40 khz signal ( dec divided by 4). when this bit is cleared and ide is set, the clkout signal will generate 38.4 khz signal ( dec fractionally divided by 25/6 see diagram below). this bit has no effect when ide is cleared. (value after reset=0) dec clkout w/ dfc=1 clkout w/ dfc=0 ide: internal demodulator enable. when this bit is set, the internal demodulator is enabled and the clock frequency at dec is expected to be 160 khz. when this bit is cleared, the internal demodulator is disabled and the clock frequency at dec is expected to be 76.8 khz. (value after reset=0) ofd: oscillator frequency difference. these bits describe the maximum difference in the frequency of the 76.8 khz oscillator crystal with respect to the frequency of the transmitter. these limits should be the worst case difference in frequency due to all conditions including but not limited to aging, temperature, and manufacturing tolerance. using a smaller frequency difference in this packet will result in lower power consumption due to higher receiver battery save ratios. note that this value is not the absolute error of the oscillator frequency provided to the flex decoder. the absolute error of the clock used by the flex transmitter must be taken into account. (e.g. if the transmitter tolerance is +/- 25 ppm and the oscillator tolerance is +/-140 ppm, the oscillator frequency difference is +/- 165 ppm and ofd should be set to 0.)(value after reset = 0)
342 ofd 1 ofd 0 frequency difference 0 0 +/- 300 ppm 0 1 +/- 150 ppm 1 0 +/- 75 ppm 1 1 +/- 0 ppm pce: partial correlation enable. when this bit is set, partial correlation of addresses is enabled. when partial correlation is enabled, the flex decoder will shutdown the receiver before the end of the last flex block which contains addresses if it can determine that none of the addresses in that flex block will match any enabled address in the flex decoder. when this bit is cleared, the receiver will be controlled as it was in previous versions of the flex decoder. (value after reset=0) sp: signal polarity. these bits set the polarity of exts1 and exts0 input signals. (value after reset=0) the polarity of the exts0 and exts1 bits will be determined by the receiver design. signal polarity sp 1 sp 0 exts1 exts0 0 0 normal normal 0 1 normal inverted 1 0 inverted normal 1 1 inverted inverted fsk modulation @ sp = 0,0 exts1 exts0 + 4800 hz 1 0 +1600 hz 1 1 - 1600 hz 0 1 - 4800 hz 0 0 sme: synchronous mode enable. when this bit is set, a status packet will be automatically sent whenever the smu (synchronous mode update) bit in the status packet is set. the host can use the sm (synchronous mode) bit in the status packet as an in-range/out-of-range indication. (value after reset=0) mot: maximum off time. this bit has no effect if ast in the timing control packet is non- zero. when ast=0 and mot=0, asynchronous a-word searches will time-out in 4 minutes. when ast=0 and mot=1, asynchronous a-word searches will time-out in 1 minute. (value after reset=0)
343 cod: clock output disable. when this bit is clear, a 38.4 khz or 40 khz (depending on the values of ide and dfc) signal will be output on the clkout pin. when this bit is set, the clkout pin will be driven low. note that setting and clearing this bit can cause pulses on the clkout pin that are less than one half the clock period. also note that when the clock output is enabled and not set for intermittent operation (see ico in this packet), the clkout pin will always output the clock signal even when the flex decoder is in reset (as long as the flex decoder oscillator is seeing clocks). further note that when the flex decoder is used in internal demodulator mode (i.e. uses a 160 khz oscillator), the clkout pin will be 80 khz from reset until the time the ide bit is set. this is because the flex decoder defaults to external demodulator mode at reset. (value after reset=0) mte: minute timer enable. when this bit is set, a status packet will be sent at one minute intervals with the mt (minute time-out) bit in the status packet set. when this bit is clear, the internal one-minute timer stops counting. the internal one-minute timer is reset when this bit is changed from 0 to 1 or when the mtc (minute timer clear) bit in the control packet is set. note that the minute timer will not be accurate using a 160 khz oscillator until the ide bit is set. (value after reset=0) lbp: low battery polarity. this bit defines the polarity of the flex decoder? lobat pin. the lb bit in the status packet is initialized to the inverse value of this bit when the flex decoder is turned on (by setting the on bit in the control packet). when the flex decoder is turned on, the first low battery update in the status packet will be sent to the host when a low battery condition is detected on the lobat pin. setting this bit means that a high on the lobat pin indicates a low voltage condition. (value after reset=0) ico: intermittent clock out. when this bit is clear and cod is clear, a 38.4 khz or 40 khz (depending on the values of ide and dfc) signal will be output on the clkout pin. when this bit is set and cod is clear, the clock will only be output on the clkout pin while the receiver is not in the off state. the clock will be output for a few cycles before the receiver transitions from the off state and for a few cycles after the receiver transitions to the off state (this is to insure that the receiver receives enough clocks to detect and process the changes to and from the off state). the clkout pin will be driven low when it is not driving a clock. note that when the clock is automatically enabled and disabled (i.e. when ico is set), the clkout signal transitions will be clean (i.e. no pulses less than half the clock period) when it transitions between no clock and clocked output. this bit has no effect when cod is set. (value after reset=0)
344 12.3.3 control packet the control packet defines a number of different control bits for the flex decoder. the id of the control packet is 2. table 12-5 control packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 0 0 00010 byte 2 ff 7 ff 6 ff 5 ff 4 ff 3 ff 2 ff 1 ff 0 byte 1 0 spm ps 1 ps 0 0000 byte 0 0 sbi 0 mtc 0 0 eae on ff: force frame 0-7. these bits enable and disable forcing the flex decoder to look in frames 0 through 7. when an ff bit is set, the flex decoder will decode the corresponding frame. unlike the af bits in the frame assignment packets, the system collapse of a flex system will not affect frames assigned using the ff bits (e.g. where as setting af 0 to 1 when the system collapse is 5 will cause the decoder to decode frames 0, 32, 64, and 96, setting ff 0 to 1 when the system collapse is 5 will only cause the decoder to decode frame 0.). this may be useful for acquiring transmitted time information or channel attributes (e.g. local id). (value after reset=0) spm: single phase mode. when this bit is set, the flex decoder will decode only one phase of the transmitted data. when this bit is clear, the flex decoder will decode all of the phases it receives. a change to this bit while the flex decoder is on, will not take affect until the next block 0 of the next decoded frame. (value after reset=0) ps: phase select. when the spm bit is set, these bits define what phase the flex decoder should decode according to the following table. this value is determined by the service provider. a change to these bits while the flex decoder is on, will not take affect until the next block 0 of a frame. (value after reset=0) ps value phase decoded (based on flex data rate) ps 1 ps 0 1600bps 3200bps 6400bps 00 a a a 01 a a b 10 a c c 11 a c d sbi: send block information words 2-4. when this bit is set, any errored or time related block information words 2-4 will be sent to the host. see 12.4.1, block information word packet for a description of the words sent. (value after reset=0)
345 mtc: minute timer clear. setting this bit will cause the one minute timer to restart from 0. eae: end of addresses enable. when this bit is set, the ea bit in the status packet will be set immediately after the flex decoder decodes the last address word in the frame if any of the enabled flex decoder addresses was detected in the frame. when this bit is cleared, the ea bit will never be set. on: turn on decoder. set if the flex decoder should be decoding flex signals. clear if signal processing should be off (very low power mode). if the on bit is changed twice and the control packets making the changes are received within 2ms of each other, the flex decoder may ignore the double change and stay in its original state (e.g. if it is turned off then on again within 2ms it may stay on and ignore the off pulse). therefore it is recommended that the host insures a minimum of 2ms between changes in the on bit. (value after reset=0) note: turning off the flex decoder must be done using the following sequence. this sequence is performed automatically by the flexstack software version 1.2 and greater. 1. turn off the flex decoder by sending a control packer with the on bit cleared. 2. turn on the flex decoder by sending a control packer with the on bit set. 3. turn off the flex decoder by sending a control packer with the on bit cleared. timing between these steps is specified below and is measured from the positive edge of the last clock of one packet to the positive edge of the last clock of the next packet: ? the minimum time between steps 1 and 2 is 2ms or the programmed shut down time, whichever is greater. the programmed shut down time is the sum of all the of the times programmed in the used receiver shut down settings packets. ? there is no maximum time between steps 1 and 2. ? the minimum time between steps 2 and 3 is 2ms. ? the maximum time between steps 2 and 3 is the programmed warm up time minus 2ms. the programmed warm up time is the sum of all the of the times programmed in the used receiver warm up settings packets. 12.3.4 all frame mode packet the all frame mode packet is used to decrement temporary address enable counters by one, decrement the all frame mode counter by one, and/or enable or disable forcing all frame mode. all frame mode is enabled if any temporary address enable counter is non-zero, the all frame mode counter is non-zero, or the force all frame mode bit is set. if all frame mode is enabled, the flex decoder will attempt to decode every frame and send a status packet with the eof (end-of-frame) bit set at the end of every frame. both the all frame mode counter and the temporary address enable counters can only be incremented internally by the flex decoder and can only be decremented by the host. the flex decoder will increment a temporary address enable counter whenever a short instruction vector is received assigning the corresponding temporary address.
346 see 12.5.4, operation of a temporary address for details. the flex decoder will increment the all frame mode counter whenever an alphanumeric, hex / binary, or secure vector is received. when the host determines that a message associated with a temporary address, or a fragmented message has ended, then the appropriate temporary address counter or all frame mode counter should be decremented by writing an all frame mode packet to the flex decoder in order to exit the all frame mode, thereby improving battery life. see 12.5.3, building a fragmented message for details. neither the temporary address enable counters nor the all frame mode counter can be incremented past the value 127 (i.e. it will not roll-over) or decremented past the value 0. the temporary address enable counters and the all frame mode counter are initialized to 0 at reset and when the decoder is turned off. the id of the all frame mode packet is 3. table 12-6 all frame mode packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 0 0 00011 byte 2 daf faf 0 00000 byte 1 dta 15 dta 14 dta 13 dta 12 dta 11 dta 10 dta 9 dta 8 byte 0 dta 7 dta 6 dta 5 dta 4 dta 3 dta 2 dta 1 dta 0 daf: decrement all frame counter. setting this bit decrements the all frame mode counter by one. if a packet is sent with this bit clear, the all frame mode counter is not affected. (value after reset =0) faf: force all frame mode. setting this bit forces the flex decoder to enter all frame mode. if this bit is clear, the flex decoder may or may not be in all frame mode depending on the status of the all frame mode counter and the temporary address enable counters. this may be useful in acquiring transmitted time information. (value after reset=0) dta: decrement temporary address enable counter. when a bit in this word is set, the corresponding temporary address enable counter is decremented by one. when a bit is cleared, the corresponding temporary address enable counter is not affected. when a temporary address enable counter reaches zero, the temporary address is disabled.(value after reset=0)
347 12.3.5 operator messaging address enable packet the contents of this section apply to the flex roaming decoder. they are not applicable to the flex non-roaming decoder. the operator messaging address enable packet is used to enable and disable the built-in flex operator messaging addresses. enabling and disabling operator messaging addresses does not affect what frames the decoder ic decodes. to decode the proper frames, the host must modify the ff bits in the control packet or the af bits in the frame assignment packets. the id of the operator messaging address enable packet is 4. table 12-7 system address enable packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 0 0 00100 byte 2 0 0 0 00000 byte 1 oae 15 oae 14 oae 13 oae 12 oae 11 oae 10 oae 9 oae 8 byte 0 oae 7 oae 6 oae 5 oae 4 oae 3 oae 2 oae 1 oae 0 oae: operator messaging address enable. when a bit is set, the corresponding operator messaging address is enabled. when it is cleared, the corresponding operator messaging address is disabled. oae 0 through oae 15 corresponds to the hexadecimal operator messaging address values of 1f7810 through 1f781f respectively. (value after reset=0) 12.3.6 roaming control packet the contents of this section apply to the flex roaming decoder. they are not applicable to the flex non-roaming decoder. the roaming control packet controls the features of the flex decoder that allow implementation of a roaming device. the id of the roaming control packet is 5. table 12-8 roaming control packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 0 0 00101 byte 2 irs nbc mcm is1 sdf rsp snd cnd byte 1 rnd abi sas das 0 0 0 0 byte 0 0 0 mfc 1 mfc 0 0 0 mco 1 mco 0
348 irs: ignore re-synchronization signal. when this bit is set, the flex decoder will not go asynchronous when detecting an ar or ar signal during searches for a-words. it will merely report that the re-synchronization signal was received by setting rsr to 1 in the roaming status packet. this allows the host to decide what to do when the paging device is synchronous to more than one channel and only one channel is sending the re-synchronization signal. it also prevents the flex decoder from losing synchronization when it detects the re-synchronization signal while the paging device is checking an unknown channel. this bit is set and cleared by the host. (value after reset=0) nbc: network bit check. setting this bit will enable reporting of the received network bit value (nbu and n) in the roaming status packet. setting this bit also makes the flex decoder abandon a frame after the frame info word without synchronizing to the frame if the frame information word is uncorrectable or if the n bit in the frame information word is not set. if the flex decoder was in synchronous mode when this occurred (probably due to synchronizing to a second channel), it will maintain synchronization to the original channel. if the flex decoder was in asynchronous mode when this occurred, it will stay in asynchronous mode and end the a-word search. this is done to avoid synchronizing to a non-roaming channel when searching for roaming channels. this bit is set and cleared by the host. (value after reset=0) mcm: manual collapse mode. when this bit is set, the flex decoder behaves as if the system collapse was 7. the flex decoder will not apply the received system collapse to the af bits. when this bit is set, the received system collapse is reported to the host via scu and rsc in the roaming status packet. this is so the host can modify the af bits based on the system collapse of the channel. this bit is set and cleared by the host. (value after reset=0) is1: invert exts1. setting this bit inverts the expected polarity of the exts1 pin from the way it is configured by sp 1 in the configuration packet (e.g. if both is1 and sp 1 are set, the polarity of the exts1 pin is untouched). this bit is intended to be changed when a change in a channel changes the polarity of the received signal. this bit is set and cleared by the host. this bit has the equivalent effect when using the internal demodulator. (value after reset=0) sdf: stop decoding frame. setting this bit causes the flex decoder to stop decoding a frame without losing frame synchronization. this bit is set by the host, and cleared by the flex decoder once it has been processed. the packet with the sdf bit set must be sent after receiving the status packet with ea bit set. it must be sent within 40ms of the end of block in which the flex decoder set the ea bit. (value after reset=0) rsp: receiver shutdown packet enable. when this bit is set, a receiver shutdown packet will be sent whenever the receiver is shut down. the receiver shutdown packet informs the host that the receiver shutdown, and how long it will be before the flex decoder will automatically warm the receiver back up. (value after reset=0) snd: start noise detect. setting this bit while the flex decoder is battery saving will cause it to warm-up the receiver, run a noise detect, and report the result of the noise detect via ndr in the
349 roaming status packet. this bit is set by the host, and cleared by the flex decoder once it has been processed. if the time comes for the flex decoder to warm up automatically or the sas bit is set while an snd is being processed, the noise detect will be abandoned and the abandoned noise detect result (ndr = 01) will be sent in the roaming status packet. (value after reset=0) cnd: continuous noise detect. setting this bit will cause the flex decoder to do continuous noise detects during the decoded block data of a frame. the results of the noise detect will only be reported if noise is detected (ndr = 11). only one noise detected result (ndr=11) will be sent per block. if the flex decoder has not completed a noise detect when it shuts down for the frame, that noise detect will be abandoned, but no abandon result (ndr=01) will be sent. this bit is set and cleared by the host. (value after reset=0) rnd: report noise detects. setting this bit will cause the flex decoder to report the results of the noise detects it does under normal asynchronous operation (when first turned on and when asynchronous). the results of the noise detect will be reported via ndr in the roaming status packet. this bit is set and cleared by the host. (value after reset=0) abi: all block information words. when this bit is set, the flex decoder will send all received block information words 2-4 to the host. note: setting the sbi bit in the control packet only enables errored and real time clock related block info words. (value after reset=0) sas: start a-word search. setting this bit while in asynchronous battery save mode will cause the flex decoder to warm-up the receiver and run an a-word search. if, during the a-word search, the flex decoder finds sufficient flex signal, it will enter synchronous mode and start decoding the frame. if the a-word search times-out without finding sufficient flex signal, it will battery save and continue doing periodic noise detects. the time-out for the a-word searches is controlled by the ast bits in the timing control packet and the mot bit in the configuration packet. the a-word search takes priority over noise detects. therefore, if the flex decoder is performing an a-word search and the time comes to do automatic noise detect, the noise detect will not be performed. this bit is set by the host, and cleared by the flex decoder once it has been acted on. (value after reset=0) das: disable a-word search. when this bit is set, an a-word search will not automatically occur after a noise detect in asynchronous mode finds flex signal. this includes automatic noise detects and noise detects initiated by the host by setting snd. the flex decoder will shut down the receiver after the noise detect completes regardless of the result. when this bit is cleared, a- word searches will occur after a noise detect finds signal in asynchronous mode. (value after reset=0) mfc: missed frame control. these bits control the frames for which missing frame data (ms1, mfi, ms2, mbi, and maw) is reported in the roaming status packet. (value after reset=0)
350 mfc 1 mfc 0 missing frame data reported 0 0 never 0 1 only during frames 0 through 3 1 0 only during frames 0 through 7 1 1 always mco: maximum carry on. the value of these bits sets the maximum carry on that the flex decoder will follow. for example, if the flex decoder receives a carry on of 3 over the air and mco is set to 1, the flex decoder will only carry on for one frame. (value after reset=3) 12.3.7 timing control packet the contents of this section apply to the flex roaming decoder. they are not applicable to the flex non-roaming decoder. the timing control packet gives the host control of the timing used when the flex decoder is in asynchronous mode. the packet id for the timing control packet is 6. table 12-9 timing control packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 0 0 01111 byte 2 0 0 0 00000 byte 1 ast 7 ast 6 ast 5 ast 4 ast 3 ast 2 ast 1 ast 0 byte 0 abt 7 abt 6 abt 5 abt 4 abt 3 abt 2 abt 1 abt 0 ast: a-word search time. the value of these bits sets the a-word search time for all asynchronous a-word searches in units of 80ms (e.g. value of 1 is 80ms, value of 2 is 160ms, etc.) if the value is 0, the flex decoder defaults to the 1-minute (mot=1) or 4-minute (mot=0) a- word search time controlled by the mot bit in the configuration packet. (value after reset=0) abt: asynchronous battery-save time. the value of these bits sets the battery save time (time from the beginning of one automatic noise detect to the beginning of the next automatic noise detect) in asynchronous mode in units of 80ms (e.g. value of 1 is 80ms, value of 2 is 160ms, etc.) if the value is 0, the battery save time is set to the default value of 1.5 seconds. the minimum allowed abt is 320ms, therefore values of 1, 2, 3, and 4 are invalid. (value after reset=0)
351 12.3.8 receiver line control packet this packet gives the host control over the settings on the receiver control lines (s0-s7) in all modes except reset. in reset, the receiver control lines are in high impedance settings. the id for the receiver line control packet is 15 (decimal). table 12-10 receiver line control packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 0 0 01111 byte 2 0 0 0 00000 byte 1 frs 7 frs 6 frs 5 frs 4 frs 3 frs 2 frs 1 frs 0 byte 0 cls 7 cls 6 cls 5 cls 4 cls 3 cls 2 cls 1 cls 0 frs: force receiver setting. setting a bit to one will cause the corresponding cls bit in this packet to override the internal receiver control settings on the corresponding receiver control line (s0-s7). clearing a bit gives control of the corresponding receiver control lines (s0-s7) back to the flex decoder.(value after reset=0) cls: control line setting. if the corresponding frs bit was set in this packet, these bits define what setting should be applied to the corresponding receiver control lines.(value after reset=0) 12.3.9 receiver control configuration packets these packets allow the host to configure what setting is applied to the receiver control lines s0- s7, how long to apply the setting, and when to read the value of the lobat input pin. for a more detailed description of how the flex decoder uses these settings see 12.5.1, receiver control. the flex decoder defines 12 different receiver control settings. proper operation is not guaranteed if these settings are changed when decoding is enabled (i.e. the on bit in the control packet is set). the ids for these packets range from 16 to 27 (decimal). 1. receiver off setting packet table 12-11 receiver off setting packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 0 0 10000 byte 2 0 0 0 0 lbc 0 0 0 byte 1 cls 7 cls 6 cls 5 cls 4 cls 3 cls 2 cls 1 cls 0 byte 0 st 7 st 6 st 5 st 4 st 3 st 2 st 1 st 0
352 lbc: low battery check. if this bit is set, the flex decoder will check the status of the lobat port just before leaving this receiver state. (value after reset=0) cls: control line setting. this is the value to be output on the receiver control lines (s0-s7) for this receiver state. (value after reset=0) st: step time. this is the time the flex decoder is to keep the receiver off before applying the first warm up state? receiver control value to the receiver control lines. the setting is in steps of 625?. valid values are 625? (st=01) to 159.375ms (st=ff in hexadecimal). (value after reset=625?) 2. receiver warm up setting packets table 12-12 receiver warm up setting packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 0 0 1 0 s 2 s 1 s 0 byte 2 se 0 0 0 lbc 0 0 0 byte 1 cls 7 cls 6 cls 5 cls 4 cls 3 cls 2 cls 1 cls 0 byte 0 0 st 6 st 5 st 4 st 3 st 2 st 1 st 0 s: setting number. receiver control setting for which this packet? values are to be applied. the following truth table shows the names of each of the values for s that apply to this packet. s 2 s 1 s 0 setting name 0 0 1 warm up 1 0 1 0 warm up 2 0 1 1 warm up 3 1 0 0 warm up 4 1 0 1 warm up 5 se: step enable. the receiver setting is enabled when the bit is set. if a step in the warm up sequence is disabled, the disabled step and all remaining steps will be skipped. (value after reset=0) lbc: low battery check. if this bit is set, the flex decoder will check the status of the lobat port just before leaving this receiver state. (value after reset=0) cls: control line setting. this is the value to be output on the receiver control lines (s0-s7) for this receiver state. (value after reset=0)
353 st: step time. this is the time the flex decoder is to wait before applying the next state? receiver control value to the receiver control lines. the setting is in steps of 625?. valid values are 625? (st=01) to 79.375ms (st=7f in hexadecimal). (value after reset=625?) 3. 3200sps sync setting packets table 12-13 3200sps sync setting packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 0 0 10110 byte 2 0 0 0 0 lbc 0 0 0 byte 1 cls 7 cls 6 cls 5 cls 4 cls 3 cls 2 cls 1 cls 0 byte 0 0 st 6 st 5 st 4 st 3 st 2 st 1 st 0 lbc: low battery check. if this bit is set, the flex decoder will check the status of the lobat port just before leaving this receiver state. (value after reset=0) cls: control line setting. this is the value to be output on the receiver control lines (s0-s7) for this receiver state. (value after reset=0) st: step time. this is the time the flex decoder is to wait before expecting good signals on the exts1 and exts0 signals after warming up. the setting is in steps of 625?. valid values are 625? (st=01) to 79.375ms (st=7f in hexadecimal). (value after reset=625?) 4. receiver on setting packets table 12-14 receiver on setting packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 0 0 1 s 3 s 2 s 1 s 0 byte 2 0 0 0 0 lbc 0 0 0 byte 1 cls 7 cls 6 cls 5 cls 4 cls 3 cls 2 cls 1 cls 0 byte 0 0 0 0 00000
354 s: setting number. receiver control setting for which this packet? values are to be applied. the following truth table shows the names of each of the values for s that apply to this packet. s 3 s 2 s 1 s 0 setting name 0 1 1 1 1600sps sync 1 0 0 0 3200sps data 1 0 0 1 1600sps data lbc: low battery check. if this bit is set, the flex decoder will check the status of the lobat port just before leaving this receiver state. (value after reset=0) cls: control line setting. this is the value to be output on the receiver control lines (s0-s7) for this receiver state. (value after reset=0) 5. receiver shut down setting packets table 12-15 receiver shut down setting packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 0 0 1101s byte 2 se 0 0 0 lbc 0 0 0 byte 1 cls 7 cls 6 cls 5 cls 4 cls 3 cls 2 cls 1 cls 0 byte 0 0 0 st 5 st 4 st 3 st 2 st 1 st 0 s: setting number. receiver control setting for which this packet? values are to be applied. the following truth table shows the names of each of the values for s that apply to this packet. s setting name 0 shut down 1 1 shut down 2 se: step enable. the receiver setting is enabled when the bit is set. if a step in the shut down sequence is disabled, all steps following the disabled step will be ignored. (value after reset=0) lbc: low battery check. if this bit is set, the flex decoder will check the status of the lobat port just before leaving this receiver state. (value after reset=0) cls: control line setting. this is the value to be output on the receiver control lines (s0-s7) for this receiver state. (value after reset=0)
355 st: step time. this is the time the flex decoder is to wait before applying the next state? receiver control value to the receiver control lines. the setting is in steps of 625?. valid values are 625? (st=01) to 39.375ms (st=3f in hexadecimal). (value after reset=625?) 12.3.10 frame assignment packets the flex protocol defines that each address of a flex pager is assigned a home frame and a battery cycle. the flex decoder must be configured so that a frame that is assigned by one or more of the addresses?home frames and battery cycles has its corresponding configuration bit set. for example, if the flex decoder has one enabled address and it is assigned to frame 3 with a battery cycle of 4, the af bits for frames 3, 19, 35, 51, 67, 83, 99, and 115 should be set and the af bits for all other frames should be cleared. when the flex decoder is configured for manual collapse mode by setting the mcm bit in the roaming control packet, the flex decoder will not apply the received system collapse to the af bits. the host should set the af bits for all frames that should be decoded on all channels. for example, if frames 0 and 64 should be decoded on one channel and frames 4, 36, 68, and 100 should be decoded on another channel, all six of the corresponding af bits should be set. the host can then change the receiver? carrier frequency after the flex decoder decodes frames 0, 36, 64, and 100. there are 8 frame assignment packets. the packet ids for these packets range from 32 to 39 (decimal). table 12-16 frame assignment packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 0 1 0 0 f 2 f 1 f 0 byte 2 0 0 0 00000 byte 1 af 15 af 14 af 13 af 12 af 11 af 10 af 9 af 8 byte 0 af 7 af 6 af 5 af 4 af 3 af 2 af 1 af 0 f: frame range. this value determines which 16 frames correspond to the 16 af bits in the packet according to the following table. at least one of these bits must be set when the flex decoder is turned on by setting the on bit in the control packet. (value after reset=0)
356 f 2 f 1 f 0 af 15 af 0 0 0 0 frame 127 frame 112 0 0 1 frame 111 frame 96 0 1 0 frame 95 frame 80 0 1 1 frame 79 frame 64 1 0 0 frame 63 frame 48 1 0 1 frame 47 frame 32 1 1 0 frame 31 frame 16 1 1 1 frame 15 frame 0 af: assigned frame. if a bit is set, the flex decoder will consider the corresponding frame to be assigned via an address? home frame and pager collapse. (value after reset=0) 12.3.11 user address enable packet the user address enable packet is used to enable and disable the 16 user address words. although the host is allowed to change the user address words while the flex decoder is decoding flex signals, the host must disable a user address word before changing it. the id of the user address enable packet is 120 (decimal). table 12-17 user address enable packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 1 1 11000 byte 2 0 0 0 00000 byte 1 uae 15 uae 14 uae 13 uae 12 uae 11 uae 10 uae 9 uae 8 byte 0 uae 7 uae 6 uae 5 uae 4 uae 3 uae 2 uae 1 uae 0 uae: user address enable. when a bit is set, the corresponding user address word is enabled. when it is cleared, the corresponding user address word is disabled. uae 0 corresponds to the user address word configured using a packet id of 128, and uae15 corresponds to the user address word configured using a packet id of 143. (value after reset=0)
357 12.3.12 user address assignment packets the flex decoder has 16 user address words. each word can be programmed to be a short address, part of a long address, or the first part of a network id . the addresses are configured using the address assignment packets. each user address can be configured as long or short and tone-only or regular (network id? are short and regular). although the host is allowed to send these packets while the flex decoder is on, the host must disable the user address word by clearing the corresponding uae bit in the user address enable packet before changing any of the bits in the corresponding user address assignment packet. this method allows for easy reprogramming of user addresses without disrupting normal operation. the ids for these packets range from 128 to 143 (decimal). table 12-18 user address assignment packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 1 0 0 0 a 3 a 2 a 1 a 0 byte 2 0 la toa a 20 a 19 a 18 a 17 a 16 byte 1 a 15 a 14 a 13 a 12 a 11 a 10 a 9 a 8 byte 0 a 7 a 6 a 5 a 4 a 3 a 2 a 1 a 0 a: user address word number. this specifies which address word is being configured. a zero in this field corresponds to address index zero (ai = 0) in the address packet received from the flex decoder when an address is detected. see 12.4.2, address packet for a description of the address index field. la: long address. when this bit is set, the address is considered a long address. both words of a long address must have this bit set. the first word of a long address must have an even address index and the second word must be in the address index immediately following the first word. toa: tone-only address. when this bit is set, the flex decoder will consider this address a tone-only address and will not decode a vector word when the address is received. if the toa bit of a long address word is set, the toa bit of the other word of the long address must also be set. a: address word. this is the 21 bit value of the address word. valid flex messaging addresses or network id? may be used.
358 12.4 decoder-to-host packet descriptions the following sections describe the packets of information that will be sent from the flex decoder to the host. in all cases the packets are sent msb first (bit 7 of byte 3 = bit 31 of the packet = msb). the flex decoder decides what data should be sent to the host. if the flex decoder is disabled through the checksum feature (see 12.3.1, checksum packet for a description of the checksum feature) the part id packet will be sent. data packets relating to data received over the air are buffered in the 32 packet transmit buffer. the data packets include block information word packets, address packets, vector packets, and message packets. if the flex decoder is enabled and a receiver shutdown packet is pending, the receiver shutdown packet will be sent. if there is no receiver shutdown packet pending, but there is a roaming status packet pending, the roaming status packet will be sent. if neither the receiver shutdown packet nor the roaming status packet is pending and there is data in the transmit buffer, a packet from the transmit buffer will be sent. otherwise, the flex decoder will send the status packet (which is not buffered). in the event of a buffer overflow, the flex decoder will automatically stop decoding and clear the buffer. it is recommended that the host be designed to empty the fifo buffer every block with enough time left over to read a status packet. this would ensure that any applicable status packet would be received within 1 block of the new status being available. part id register receiver shutdown register roaming status register spi transmit register mux miso 32 32 32 32 32 32 32 figure 12-8 flex decoder spi transmit functional block diagram
359 12.4.1 block information word packet the block information field is the first field following the synchronization codes of the flex protocol. this field contains information about the frame such as number of addresses and messages, information about current time, the channel id, channel attributes, etc. the first block information word of each phase is used internally to the flex decoder and is never transmitted to the host with the exception of the system collapse which is sent to the host when the flex decoder is in manual collapse mode. time block information words 2-4 can be optionally sent to the host by setting the sbi bit in the control packet (see 12.3.3, control packet). all block information words 2-4 can be optionally sent to the host by setting the abi bit in the roaming control packet. when the sbi or abi bit is set and any block information word 2-4 is received with an uncorrectable number of biterrors, the flex decoder will send the block information word to the host with the e bit setregardless of the value of the f field in the block information word. the flex decoder does not support decoding of the vector and message words associated with the data/system message block info word (f=101). the id of a block information word packet is 0 (decimal). table 12-19 block information word packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 0 1 00000 byte 2 e p 1 p 0 xxf 2 f 1 f 0 byte 1 x x s 13 s 12 s 11 s 10 s 9 s 8 byte 0 s 7 s 6 s 5 s 4 s 3 s 2 s 1 s 0 e: set if more than 2 bit errors are detected in the word or if the check character calculation fails after error correction has been performed. p: phase on which the block information word was found (0=a, 1=b, 2=c, 3=d) x: unused bits. the value of these bits is not guaranteed. f: word format type. the value of these bits modify the meaning of the s bits in this packet as described in the biw word descriptions in the s bit definition below. s: these are the information bits of the block information word. the definition of these bits depend on the f bits in this packet. the following table describes the block information words.
360 f 2 f 1 f 0 s 13 s 12 s 11 s 10 s 9 s 8 s 7 s 6 s 5 s 4 s 3 s 2 s 1 s 0 description 00 0 * 1 i 8 i 7 i 6 i 5 i 4 i 3 i 2 i 1 i 0 c 4 c 3 c 2 c 1 c 0 local id, coverage zone 00 1 * 2 m 3 m 2 m 1 m 0 d 4 d 3 d 2 d 1 d 0 y 4 y 3 y 2 y 1 y 0 month, day, year 01 0 * 2 s 2 s 1 s 0 m 5 m 4 m 3 m 2 m 1 m 0 h 4 h 3 h 2 h 1 h 0 second, minute, hour 01 1 * 1 reserved by flex protocol for future use 10 0 * 1 reserved by flex protocol for future use 10 1 * 2 z 9 z 8 z 7 z 6 z 5 z 4 z 3 z 2 z 1 z 0 a 3 a 2 a 1 a 0 system message 11 0 * 1 reserved by flex protocol for future use 11 1 * 1 c 9 c 8 c 7 c 6 c 5 c 4 c 3 c 2 c 1 c 0 t 3 t 2 t 1 t 0 country code, traffic management flags notes: 1. will be decoded only if the abi bit is set. 2. will be decoded only if the sbi or abi bit is set. 12.4.2 address packet the address field follows the block information field in the flex protocol. it contains all of the addresses in the frame. if less than three bit errors are detected in a received address word and it matches an enabled address assigned to the flex decoder, an address packet will be sent to the host processor. the address packet contains assorted data about the address and its associated vector and message. the id of an address packet is 1 (decimal). table 12-20 address packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 0 0 00001 byte 2 pa p 1 p 0 laxxxx byte 1 ai 7 ai 6 ai 5 ai 4 ai 3 ai 2 ai 1 ai 0 byte 0 toa wn 6 wn 5 wn 4 wn 3 wn 2 wn 1 wn 0 pa: priority address. set if the address was received as a priority address. p: phase on which the address was detected (0=a, 1=b, 2=c, 3=d) la: long address type. set if the address was programmed in the flex decoder as a long address. ai: address index (valid values are 0 through 15 and 128 through 159). the index identifies which of the addresses was detected. values 0 through 15 correspond to the 16 programmable
361 address words. values 128 through 143 correspond to the 16 temporary addresses . values 144 through 159 correspond to the 16 operator messaging addresses. for long addresses, the address detect packet will only be sent once and the index will refer to the second word of the address. toa: tone only address. set if the address was programmed in the flex decoder as a tone- only address. this bit will never be set for temporary or operator messaging addresses. no vector word will be sent for tone-only addresses. wn: word number of vector (2 - 87). describes the location in the frame of the vector word for the detected address. this value is invalid for this packet if the toa bit is set. x: unused bits. the value of these bits is not guaranteed. 12.4.3 vector packet the vector field follows the address field in the flex protocol. each vector packet must be matched to its corresponding address packet. the id of the vector packet is the word number where the vector word was received in the frame. this value corresponds to the wn bits sent in the associated address packet. the phase information in both the address packet and the vector packet must also match. it is important to note for long addresses, the first message word will be transmitted in the word location immediately following the associated vector. see12.5.2, message building for a message building example. in this case, the word number (identified by b 6 to b 0 ) in the vector packet will indicate the message start of the second message word if the message is longer than 1 word. there are several types of vectors - 3 types of numeric vectors, a short message / tone only vector, a hex / binary vector, an alphanumeric vector, a secure message vector, and a short instruction vector. each is described in the following pages. two of the modes of the short instruction vector is used for assigning temporary addresses that may be associated with a group call. the numeric, hex / binary, alphanumeric, and secure message vector packets have associated message word packets in the message field. the host must use the n and b bits of the vector word to calculate what message word locations are associated with the vector. the message word locations and the phase must match. four of the vectors (hex / binary, alphanumeric, secure message, and the temporary address assignment modes of the short instruction) enable the flex decoder to begin the all frame mode. this mode is required to allow for the decoding of temporary addresses and / or fragmented messages. the host disables the all frame mode after the proper time by writing to the decoder via the all frame mode packet. see 12.5.3, building a fragmented message and 12.5.4, operation of a temporary address for more information. for any address packet sent to the host (except tone-only addresses), a corresponding vector packet will always be sent. if more than two
362 bit errors are detected (via bch calculations, parity calculations, check character calculations, or value validation) in the vector word the e bit will be set and the message words will not be sent. 1. numeric vector packet table 12-21 numeric vector packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 wn 6 wn 5 wn 4 wn 3 wn 2 wn 1 wn 0 byte 2 e p 1 p 0 xxv 2 v 1 v 0 byte 1 x x k 3 k 2 k 1 k 0 n 2 n 1 byte 0 n 0 b 6 b 5 b 4 b 3 b 2 b 1 b 0 v: vector type identifier. v 2 v 1 v 0 name description 0 1 1 standard numericvector no special formatting of characters is specified 1 0 0 special format numeric vector formatting of the received characters is predetermined by special rules in the host. 1 1 1 numbered numeric vector the received information has been numbered by the service provider to indicate all messages have been properly received wn: word number of vector (2 - 87 decimal). describes the location of the vector word in the frame. e: set if more than 2 bit errors are detected in the word, if the check character calculation fails after error correction has been performed, or if the vector value is determined to be invalid. p: phase on which the vector was found (0=a, 1=b, 2=c, 3=d) k: beginning check bits of the message. n: number of message words in the message including the second vector word for long addresses (000 = 1 word message, 001 = 2 word message, etc.). for long addresses, the first message word is located in the word location that immediately follows the associated vector. b: word number of message start in the message field (3-87 decimal). for long addresses, the word number indicates the location of the second message word. x: unused bits. the value of these bits is not guaranteed.
363 2. short message / tone only vector table 12-22 short message / tone only vector packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 wn 6 wn 5 wn 4 wn 3 wn 2 wn 1 wn 0 byte 2 e p 1 p 0 xxv 2 v 1 v 0 byte 1 x x d 11 d 10 d 9 d 8 d 7 d 6 byte 0 d 5 d 4 d 3 d 2 d 1 d 0 t 1 t 0 v: 010 for a short message / tone only vector wn: word number of vector (2 - 87 decimal). describes the location of the vector word in the frame. e: set if more than 2 bit errors are detected in the word or, if after error correction, the check character calculation fails. p: phase on which the vector was found (0=a, 1=b, 2=c, 3=d) d: data bits whose definition depend on the value of t in this packet according to the following table. note that if this vector is received on a long address and the e bit in this packet is not set, the decoder will send a message packet from the word location immediately following the vector packet. except for the short message on a non-network address (t=0), all message bits in the message packet are unused and should be ignored. t 1 t 0 d 1 1 d 10 d 9 d 8 d 7 d 6 d 5 d 4 d 3 d 2 d 1 d 0 description 00 c 3 c 2 c 1 c 0 b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 short numeric: 3 numeric chars * 1 when on a messaging address 00 t 3 t 2 t 1 t 0 m 2 m 1 m 0 a 4 a 3 a 2 a 1 a 0 part of nid when on a network address 01 s 8 s 7 s 6 s 5 s 4 s 3 s 2 s 1 s 0 s 2 s 1 s 0 tone only: 8 sources (s) and 9 unused bits (s) 10 s 1 s 0 r 0 n 5 n 4 n 3 n 2 n 1 n 0 s 2 s 1 s 0 tone only: 8 sources (s), message number (n), message retrieval flag (r), and 2 unused bits (s) 1 1 spare message type note: for long addresses, an extra 5 characters are sent in the message packet immediately following the vector packet. t: message type. these bits define the meaning of the d bits in this packet. x: unused bits. the value of these bits is not guaranteed.
364 3. hex / binary, alphanumeric, and secure message vector table 12-23 hex / binary, alphanumeric, and secure message vector packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 wn 6 wn 5 wn 4 wn 3 wn 2 wn 1 wn 0 byte 2 e p 1 p 0 xxv 2 v 1 v 0 byte 1 x x n 6 n 5 n 4 n 3 n 2 n 1 byte 0 n 0 b 6 b 5 b 4 b 3 b 2 b 1 b 0 v: vector type identifier. v 2 v 1 v 0 type 0 0 0 secure 1 0 1 alphanumeric 1 1 0 hex / binary wn: word number of vector (2 - 87 decimal). describes the location of the vector word in the frame. e: set if more than 2 bit errors are detected in the word, if the check character calculation fails after error correction has been performed, or if the vector value is determined to be invalid. p: phase on which the vector was found (0=a, 1=b, 2=c, 3=d) n: number of message words in this frame including the first message word that immediately follows a long address vector. valid values are 1 through 85 decimal. b: word number of message start in the message field. valid values are 3 through 87 decimal. x: unused bits. the value of these bits is not guaranteed. note: for long addresses, the first message packet is sent from the word location immediately following the word location of the vector packet. the b bits indicate the second message word in the message field if one exists.
365 4. short instruction vector table 12-24 short instruction vector packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 wn 6 wn 5 wn 4 wn 3 wn 2 wn 1 wn 0 byte 2 e p 1 p 0 xxv 2 v 1 v 0 byte 1 x x d 10 d 9 d 8 d 7 d 6 d 5 byte 0 d 4 d 3 d 2 d 1 d 0 i 2 i 1 i 0 v: 001 for a short instruction vector wn: word number of vector (2 - 87 decimal). describes the location of the vector word in the frame. e: set if more than 2 bit errors are detected in the word or, if after error correction, the check character calculation fails. p: phase on which the vector was found (0=a, 1=b, 2=c, 3=d) d: data bits whose definition depend on the i bits in this packet according to the following table. note that if this vector is received on a long address and the e bit in this packet is not set, the decoder will send a message packet immediately following the vector packet. all message bits in the message packet are unused and should be ignored for all modes except the temporary address assignment with msn (i 2 i 1 i 0 =010). i 2 i 1 i 0 d 10 d 9 d 8 d 7 d 6 d 5 d 4 d 3 d 2 d 1 d 0 description 000a 3 a 2 a 1 a 0 f 6 f 5 f 4 f 3 f 2 f 1 f 0 temporary address assignment * 1 001d 10 d 9 d 8 d 7 d 6 d 5 d 4 d 3 d 2 d 1 d 0 11 event flags for system event 010a 3 a 2 a 1 a 0 f 6 n 5 n 4 n 3 n 2 n 1 n 0 temporary address assignment with msn * 2 0 1 1 reserved 1 0 0 reserved 1 0 1 reserved 1 1 0 reserved 1 1 1 reserved for test notes: 1. assigned temporary address (a) and assigned frame (f). see 12.5.4, operation of a temporary address for a description of the use of these fields. 2. assigned temporary address (a), msb of assigned frame (f 6 ), and message sequence number (n). the message packet sent with this instruction on long addresses contains extra frame information, see 12.5.4, operation of a temporary address for a description and for details on the use of the other fields.
366 i: instruction type. these bits define the meaning of the d bits in this packet. x: unused bits. the value of these bits is not guaranteed. 12.4.4 message packet the message field follows the vector field in the flex protocol. it contains the message data, checksum information, and may contain fragment numbers and message numbers. if the error bit of a vector word is not set and the vector word indicates that there are message words associated with the page, the message words are sent in message packets. the id of the message packet is the word number where the message word was received in the frame. table 12-25 message packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 wn 6 wn 5 wn 4 wn 3 wn 2 wn 1 wn 0 byte 2 e p 1 p 0 i 20 i 19 i 18 i 17 i 16 byte 1 i 15 i 14 i 13 i 12 i 11 i 10 i 9 i 8 byte 0 i 7 i 6 i 5 i 4 i 3 i 2 i 1 i 0 wn: word number of message word (3 - 87 decimal). describes the location of the message word in the frame. e: set if more than 2 bit errors are detected in the word. p: phase on which the message word was found (0=a, 1=b, 2=c, 3=d) i: these are the information bits of the message word. the definitions of these bits depend on the vector type and which word of the message is being received. 12.4.5 roaming status packet the contents of this section apply to the flex roaming decoder. they are not applicable to the flex non-roaming decoder. the flex decoder will automatically prompt the host to read a roaming status packet if rsr, ms1, mfi, ms2, mbi, maw, nbu, ndr 1 , ndr 0 , or scu is set.
367 table 12-26 roaming status packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 1 1 00000 byte 2 rsr ms1 mfi ms2 mbi maw nbu n byte 1 x x x xxxndr 1 ndr 0 byte 0 x x x x scu rsc 2 rsc 1 rsc 0 rsr: re-synchronization signal received. set when the flex decoder detected a re- synchronization signal and the host configured the flex decoder to ignore it via the irs bit in the roaming control packet. this bit is cleared when read. ms1: missed synchronization 1. set when the flex decoder failed to detect the first synchronization pattern (a / a ) of a flex frame and the flex decoder was configured to report missed frame information via the mfc bit in the roaming control packet. this bit is cleared when read. mfi: missed frame information word. set when the frame information word is received with an uncorrectable number of errors and the flex decoder was configured to report missed frame information via the mfc bit in the roaming control packet. this bit is cleared when read. ms2: missed synchronization 2. set when the flex decoder failed to detect the second synchronization pattern (c / c ) of a frame and flex decoder was configured to report missed frame information via the mfc bit in the roaming control packet. this bit is cleared when read. mbi: missed block information word 1. set when at least one of the block information word ones is received with an uncorrectable number of errors and flex decoder was configured to report missed frame information via the mfc bit in the roaming control packet. this bit is set no more than once per frame regardless of the number of missed block information word 1? in the frame. this bit is cleared when read. maw: missed address word. set when any address words in the address field is received with an uncorrectable number of errors and flex decoder was configured to report missed frame information via the mfc bit in the roaming control packet. this bit is set no more than once per frame regardless of the number of missed address words in the frame. this bit is cleared when read. nbu: network bit update. set when the nbc bit in the roaming control packet is set and a frame information word is received with a correctable number of errors. this bit will not be set when the frame information word is not received due to missing the first synchronization pattern (a / a ). this bit is cleared when read.
368 n: network bit value. when nbu is set, this is the value of the n bit in the last received frame information word. ndr: noise detect result. these bits indicate the result of a noise detect. the results of noise detects initiated by setting the snd bit in the roaming control packet will always be reported. the results of the automatic noise detects performed in asynchronous mode will only be reported if the rnd bit is set in the roaming control packet. when continuous noise detects during block data are enabled by setting the cnd bit in the roaming control packet, only the ?o flex signal detected result will be reported. these bits are cleared when read. ndr noise detect result 00 no information 01 noise detect was abandoned 10 flex signal detected 11 flex signal not detected scu: system collapse update. set when the flex decoder is configured for manual collapse mode by setting the mcm bit in the roaming control packet and the system collapse of a frame is received. this bit is set no more than once per frame regardless of the number of phases in the frame. this bit will not be set in frames in which no block information word ones is received properly. this bit is cleared when read. rsc: received system collapse. when scu is set, this value represents the system collapse value that was received in the frame.
369 12.4.6 receiver shutdown packet the contents of this section apply to the flex roaming decoder. they are not applicable to the flex non-roaming decoder. the shutdown packet is sent in both synchronous and asynchronous mode. it is designed to indicate to the host that the receiver is turned off and how much time there is until the flex decoder will automatically turn it back on. table 12-27 receiver shut down packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 1 1 11111 byte 2 fnv cf 6 cf 5 cf 4 cf 3 cf 2 cf 1 cf 0 byte 1 tnf 7 tnf 6 tnf 5 tnf 4 tnf 3 tnf 2 tnf 1 tnf 0 byte 0 fco naf 6 naf 5 naf 4 naf 3 naf 2 naf 1 naf 0 fnv: frame number valid. this bit is set if the last decoded frame info word was correctable and the frame number was the expected value. when in asynchronous mode, this value will be 0. cf: current frame. when in synchronous mode, this is the current frame number. this value is latched on the negative edge of the ready line when this packet is sent to the host. the value of this field is valid only if the flex decoder is in synchronous mode and the fiv bit in the status packet is set. when in asynchronous mode, this value will be 0. tnf: time to next frame. when in synchronous mode tnf indicates the time to the start of the a-word check if the flex decoder were to warm up for the next frame. when in asynchronous mode tnf indicates the time to the start of the next automatic noise detect. see ?sing the receiver shutdown packet?on page 66 for an explanation on how to use this value. this value is latched on the negative edge of the ready line when this packet is sent to the host. fco: frame carried on. set if the flex decoder is decoding the next frame due to the reception of a non-zero carry-on value in the current or a previous frame. when in asynchronous mode, this value will be 0. naf: next assigned frame. this is the frame number of the next frame the flex decoder was scheduled to decode when the receiver shut down. the value of this field is valid only if the flex decoder is in synchronous mode and the fiv bit in the status packet is set. when in asynchronous mode this value will be 0.
370 12.4.7 status packet the status packet contains various types of information that the host may require. the status packet will be sent to the host whenever the flex decoder is polled and has no other data to send. the flex decoder can also prompt the host to read the status packet due to events for which the flex decoder was configured to send it (see 12.3.2, configuration packet and 12.3.3, control packet for a detailed description of the bits). the flex decoder will prompt the host to read a status packet if the... 1. ... smu bit in the status packet and the sme bit in the configuration packet are set. 2. ... mt bit in the status packet and the mte bit in the configuration packet are set. 3. ... eof bit in the status packet is set. 4. ... lbu bit in the status packet is set. 5. ... ea bit in the status packet is set. 6. ... boe bit in the status packet is set. the id of the status packet is 127 (decimal). table 12-28 status packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 0 1 1 11111 byte 2 fiv f 6 f 5 f 4 f 3 f 2 f 1 f 0 byte 1 sm lb x x c 3 c 2 c 1 c 0 byte 0 smu lbu x mt x eof ea boe fiv: frame info valid. set when a valid frame info word has been received since becoming synchronous to the system and the f and c fields contain valid values. if this bit is clear, no valid frame info words have been received since the flex decoder became synchronous to the system. this value will change from 0 to 1 at the end of block 0 of the frame in which the 1st frame info word was properly received. it will be cleared when the flex decoder goes into asynchronous mode. this bit is initialized to 0 when the flex decoder is reset and when the flex decoder is turned off by clearing the on bit in the control packet. f: current frame number. this value is updated every frame regardless of whether the flex decoder needs to decode the frame. this value will change to its proper value for a frame at the end of block 0 of the frame. the value of these bits is not guaranteed when fiv is 0. sm: synchronous mode. this bit is set when the flex decoder is synchronous to the system. the flex decoder will set this bit when the first synchronization words are received. it will clear this bit when the flex decoder has not properly received both synchronization words in any frame for 8, 16, or 32 minutes (depending on the number of assigned frames and the system
371 collapse). this bit is initialized to 0 when the flex decoder is reset and when it is turned off by clearing the on bit in the control packet. lb: low battery. set to the value last read from the lobat pin. the host controls when the lobat pin is read via the receiver control packets. this bit is initialized to 0 at reset. it is also initialized to the inverse of the lbp bit in the configuration packet when the flex decoder is turned on by setting the on bit in the control packet. c: current system cycle number. this value is updated every frame regardless of whether the flex decoder needs to decode the frame.this value will change to its proper value for a frame at the end of block 0 of the frame. the value of these bits is not guaranteed when fiv is 0. smu: synchronous mode update. set if the sm bit has been updated in this packet. when the flex decoder is turned on, this bit will be set when the first synchronization words are found (sm changes to 1) or when the first synchronization search window after the flex decoder is turned on expires (sm stays 0). the latter condition gives the host the option of assuming the paging device is in range when it is turned on, and displaying out-of-range only after the initial a search window expires. after the initial synchronous mode update, the smu bit will be set whenever the flex decoder transitions from/to synchronous mode. cleared when read. changes in the sm bit due to turning off the flex decoder will not cause the smu bit to be set. this bit is initialized to 0 when the flex decoder is reset. lbu: low battery update. set if the value on two consecutive reads of the lobat pin yielded different results. cleared when read. the host controls when the lobat pin is read via the receiver control packets. changes in the lb bit due to turning on the flex decoder will not cause the lbu bit to be set. this bit is initialized to 0 when the flex decoder is reset. mt: minute time-out. set if one minute has elapsed. cleared when read. this bit is initialized to 0 when the flex decoder is reset. eof: end of frame. set when the flex decoder is in all frames mode and the end of frame has been reached. the flex decoder is in all frames mode if the all frames mode enable counter is non-zero, if any temporary address enabled counter is non-zero, or if the faf bit in the all frame mode packet is set. cleared when read. this bit is initialized to 0 when the flex decoder is reset. ea: end of addresses. if eae of the control packet is set and an address is detected in a frame, ea will be set after the flex decoder processes the last address in the frame. since data packets take priority over the status packet, the status packet with the ea bit set is guaranteed to come after all address packets for the frame. cleared when read. this bit is initialized to 0 when the flex decoder is reset. boe: buffer overflow error. set when information has been lost due to slow host response time. when the data packet fifo transmit buffer on the flex decoder overflows, the flex decoder clears the buffer, turns off decoding by clearing the on bit in the control packet, and sets this bit. cleared when read. this bit is initialized to 0 when the flex decoder is reset.
372 x: unused bits. the value of these bits is not guaranteed. 12.4.8 part id packet the part id packet is sent by the flex decoder whenever the flex decoder is disabled due to the checksum feature. see 12.3.1, checksum packet for a description of the checksum feature. since the flex decoder is disabled after reset, this is the first packet that will be received by the host after reset. the id of the part id packet is 255 (decimal). table 12-29 part id packet bit assignments bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 byte 3 1 1 1 11111 byte 2 mdl 1 mdl 0 cid 13 cid 12 cid 11 cid 10 cid 9 cid 8 byte 1 cid 7 cid 6 cid 5 cid 4 cid 3 cid 2 cid 1 cid 0 byte 0 rev 7 rev 6 rev 5 rev 4 rev 3 rev 2 rev 1 rev 0 mdl: model. this identifies the flex decoder model. current value is 0. cid: compatibility id. this value describes the flex decoders to which this part is backwards compatible. see table below for meaning and current value. bit indicates this ic can be used in place of value for flex tm roaming decoder ii cid 0 flex alphanumeric decoder i * 1 1 (true) cid 1 flex roaming decoder i * 2 1 (true) cid 2 flex numeric decoder 0 (false) notes: 1. compatibility to flex alphanumeric decoder ii is indicated by mdl set to 0, cid 0 set to 1, and rev greater than or equal to 7. 2. compatibility to flex roaming decoder ii is indicated by mdl set to 0, cid 1 set to 1, and rev greater than or equal to 8. rev: revision. this identifies the revision and manufacturer of the flex decoder. the following table lists the currently available part id? of the flex decoder family.
373 part id packet (hex) revision manufacturer 00 01 03 flex alphanumeric decoder i texas instruments 00 01 04 flex alphanumeric decoder i motorola semiconductor products sector 00 01 06 flex alphanumeric decoder i philips 00 01 07 flex alphanumeric decoder ii motorola semiconductor products sector 00 01 08 flex alphanumeric decoder ii texas instruments 00 03 03 flex roaming decoder i motorola semiconductor products sector 00 03 05 flex roaming decoder i texas instruments 00 03 09 flex roaming decoder ii motorola semiconductor products sector 00 03 0a flex roaming decoder ii texas instruments 00 04 01 flex numeric decoder texas instruments 00 01 15 flex alphanumeric decoder ii hitachi 00 03 15 flex roaming decoder ii hitachi
374 12.5 application notes 12.5.1 receiver control introduction: the flex decoder has 8 programmable receiver control lines (s0-s7). the host has control of the receiver warm up and shut down timing as well as all of the various settings on the control lines through configuration registers on the flex decoder. the configuration registers for most settings allow the host to configure what setting is applied to the control lines, how long to apply the setting, and if the lobat input pin is polled before changing from the setting. with this programmability, the flex decoder should be able to interface with many off-the-shelf receiver ics. when using the internal demodulator (i.e. when the ide bit of the configuration packet is set), the s0 pin becomes the input for the demodulator and the s0 register setting in the receiver control configuration packets controls the tracking mode of the peak and valley detectors for the internal data slicer. when the s0 bit is set in a receiver setting, the internal data slicer will be in fast track mode. when the s0 bit is cleared in a receiver setting, the internal data slicer will be in slow track mode. for details on the configuration of the receiver control settings, see 12.3.9, receiver control configuration packets. 1. receiver settings at reset the receiver control ports are three-state outputs which are set to the high-impedance state when the flex decoder is reset and until the corresponding frs bit in the receiver line control packet is set or until the flex decoder is turned on by setting the on bit in the control packet. this allows the designer to force the receiver control lines to the receiver off setting with external pull- up or pull-down resistors before the host can configure these settings in the flex decoder. when the flex decoder is turned on, the receiver control ports are driven to the settings configured by the ?2.3.9 receiver control configuration packets?until the flex decoder is reset again. 2. automatic receiver warm up sequence the flex decoder allows for up to 6 steps associated with warming up the receiver. when the flex decoder automatically turns on the receiver, it starts the warm up sequence 160 ms before it requires valid signals at the exts0 and exts1 input pins (or the equivalent internal signals when using the internal demodulator/data slicer). the first step of the warm up sequence involves leaving the receiver control lines in the ?ff?state for the amount of time programmed for ?arm up off time? at the end of the ?arm up off time? the first warm up setting, if enabled, is applied to the receiver control lines for the amount of time programmed for that setting. each subsequent warm up setting is applied to the receiver control lines for their corresponding time until a disabled warm up setting is found. at the end of the last used warm up setting, the ?600sps sync setting?or the ?200sps sync setting?is applied to the receiver control lines depending on the current state of the flex decoder. the sum total of all of the used warm up times and the ?arm up off time?must not exceed 160ms. if it exceeds 160ms, the flex decoder will execute the receiver shut down sequence at the end of the 160ms warm up period.
375 the receiver warm up sequence while decoding when all warm up settings are enabled is shown in figure 12-9. warm up off time warm up time 1 warm up time 2 warm up time 3 warm up time 4 warm up time5 receiver control line setting off warm up setting 1 warm up setting 2 warm up setting 3 warm up setting 4 warm up setting 5 1600sps or 3200sps sync setting possible lobat check possible lobat check possible lobat check possible lobat check possible lobat check possible lobat check exts1 & exts0 signals are expected to be valid here. 160 ms figure 12-9 automatic receiver warm up sequence 3. host initiated receiver warm up sequence the host can cause the flex decoder to warm-up the receiver in three ways: (1) by turning on the flex decoder by setting the on bit in the control packet; (2) by requesting a noise detect by setting the snd bit in the roaming control packet; or (3) by requesting an a-word search by setting the sas bit in the roaming control packet. when the flex decoder warms up the receiver in response to a host request, the first warm up setting, if enabled, is applied to the receiver control lines for the amount of time programmed for that setting. each subsequent warm up setting is applied to the receiver control lines for their corresponding time until a disabled warm up setting is found. once a disabled warm up setting is found, the ?200sps sync setting? (for on and snd warm ups) or the ?600sps sync setting?(for sas warm ups) is applied to the receiver control lines and the decoder does not expect valid signal until after the ?200sps sync warm up time (for on, snd, and sas warm ups) has expired. in figure 12-10 the receiver warm up sequence when the host initiates a warm-up sequence and when all warm up settings are enabled is shown. warm up time 1 warm up time 2 warm up time 3 warm up time 4 warm up time5 warm up time sync 3200sps receiver control line setting off warm up setting 1 warm up setting 2 warm up setting 3 warm up setting 4 warm up setting 5 3200sps sync setting possible lobat check possible lobat check possible lobat check possible lobat check possible lobat check possible lobat check exts1 & exts0 signals are expected to be valid here. figure 12-10 host initiated receiver warm up sequence
376 4. receiver shut down sequence the flex decoder allows for up to 3 steps associated with shutting down the receiver. when the flex decoder decides to turn off the receiver, the first shut down setting, if enabled, is applied to the receiver control lines for the corresponding shut down time. at the end of the last used shut down time, the ?ff?setting is applied to the receiver control lines. if the first shut down setting is not enabled, the flex decoder will transition directly from the current on setting to the ?ff setting. the receiver turn off sequence when all shut down settings are enabled is shown in figure 12-11. if the receiver is on or being warmed up when the decoder is turned off (by clearing the on bit in the control packet), the flex decoder will execute the receiver shutdown sequence. if the flex decoder is executing the shut down sequence when the flex decoder is turned on (by setting the on bit in the control packet), the flex decoder will complete the shut down sequence before starting the warm up sequence. shut down setting 1 shut down time 2 receiver control line setting 1600sps or 3200sps sync or data setting shut down setting 2 off possible lobat check possible lobat check possible lobat check shut down time 1 figure 12-11 receiver shut down sequence 5. miscellaneous receiver states in addition to the warm up and shut down states, the flex decoder has four other receiver states. when these settings are applied to the receiver control lines, the flex decoder will be decoding the exts1 and exts0 input signals (or the equivalent internal signals when using the internal demodulator/data slicer). the timing of these signals and their duration depends on the data the flex decoder decodes. the four settings are as follows: ? 1600sps sync setting: this setting is applied when the flex decoder is searching for a 1600 symbols per second signal. ? 3200sps sync setting: this setting is applied when the flex decoder is searching for a 3200 symbols per second signal. ? 1600sps data setting: this setting is applied after the flex decoder has found the c or c sync word in a 1600 symbols per second frame.
377 ? 3200sps data setting: this setting is applied after the flex decoder has found the c or c sync word in a 3200 symbols per second frame. some examples of how these settings will be used in the flex decoder are shown in figure 12-12. flex signal receiver control line setting example #1 receiver control line setting example #2 block 10 sync 1 sync 2 block 0 frame info 1600 sps data or 3200 sps data or last used warm up setting 1600 sps data or 3200 sps data or last used warm up setting 1600 sps sync setting 1600 sps data setting 3200sps sync setting 3200sps data setting possible lobat check possible lobat check possible lobat check possible lobat check possible lobat check 1600sps sync setting figure 12-12 examples of receiver control transitions 6. low battery detection the flex decoder can be configured to poll the lobat input pin at the end of every receiver control setting. this check can be enabled or disabled for each receiver control setting. if the poll is enabled for a setting, the pin will be read just before the flex decoder changes the receiver control lines from that setting to another setting. the flex decoder will send a status packet whenever the value on two consecutive reads of the lobat pin yields different results. 12.5.2 message building a simple message consists of an address packet followed by a vector packet indicating the word numbers of associated message packets.the tables below show a more complex example of receiving three messages and two block information word packets in the first two blocks of a 2 phase 3200 bps, flex frame. note that the messages shown may be portions of fragmented or group messages. note further that in the case of a 6400 bps flex signal, there would be four phases: a, b, c and d, and in the case of a 1600 bps signal there would be only a single phase a. table 12-30 shows the block number, word number (wn) and word content of both phases a and c. note contents of words not meant to be received by the host are left blank. each phase begins with a block information word (wn 0), this is not sent to the host. the first message is in phase a and has an address (wn 3), vector (wn 7) and three message words (wn9 - 11). the second message is also in phase a and has an address (wn 4), a vector (wn 8) and four message words
378 (wn 12 - 15). the third message is in phase c and has a 2 word long address (wn 5 - 6) followed by a vector (wn 10) and three message words. since the third message is sent on a long address, the first message word (wn 11) begins immediately after the vector. the vector indicates the location of the second and third message words (wn 14 - 15). table 12-30 flex signal block word number phase a phase c 0 0 biw1 biw1 1 biw 3 address 1 biw 4 address 2 5 long address 3 word 1 6 long address 3 word 2 7 vector 1 1 8 vector 2 9 message 1,1 10 message 1,2 vector 3 11 message 1,3 message 3,1 12 message 2,1 13 message 2,2 14 message 2,3 message 3,2 15 message 2,4 message 3,3 table 12-31 shows the sequence of packets received by the host. the flex decoder processes the flex signal one block at a time, and one phase at a time. thus, the address and vector information in block 0 phase a is sent to the host in packets 1-3. then information in block 0 phase c, two block information words and one long address, is sent to the host in packets 4-6. packets 7 - 18 correspond to information in block 1, processed in phase a first and phase c second.
379 table 12-31 flex decoder packet sequence packet packet type phase word number comment 1st address a n.a. (7) address 1 has a vector located at wn 7 2nd address a n.a. (8) address 2 has a vector located at wn 8 3rd vector a 7 vector for address 1: message words located at wn = 9 to 11, phase a 4th biw c n.a. if biws enabled, then biw packet sent 5th biw c n.a. if biws enabled, then biw packet sent 6th long address c n.a. (10) long address 3 has a vector beginning in word 10 of phase c 7th vector a 8 vector for address 2: message words located at wn = 12 to 15, phase a 8th message a 9 message information for address 1 9th message a 10 message information for address 1 10th message a 11 message information for address 1 11th message a 12 message information for address 2 12th message a 13 message information for address 2 13th message a 14 message information for address 2 14th message a 15 message information for address 2 15th vector c 10 vector for long address 3: message words located at wn = 14 - 15, phase c 16th message c 11 second word of long vector is first message information word of address 3 17th message c 14 message information for address 3 18th message c 15 message information for address 3 the first message is built by relating packets 1, 3, and 8-10. the second message is built by relating packets 2, 7 and 11 - 14. the third message is built by relating packets 6 and 15 - 18. additionally, the host may process block information in packets 4 and 5 for time setting information. 12.5.3 building a fragmented message the longest message which will fit into a frame is 84 code words total of message data. three alpha characters per word yields a maximum message of 252 characters in a frame assuming no other traffic. messages longer than this value must be sent as several fragments.
380 additional fragments can be expected when the ?ontinue bit?in the 1st message word is set. this causes the pager to examine every following frame for an additional fragment until the last fragment with the continue bit reset is found. the only requirement relating to the placement in time of the remaining fragments is that no more than 32 frames (1 minute) or 128 frames (4 minutes) as indicated by the service provider may pass between fragment receptions. each fragment contains a check sum character to detect errors in the fragment, a fragment number 0, 1, or 2 to detect missing fragments, a message number to identify which message the fragment is a part, and the continue bit which either indicates that more fragments are in queue or that the last fragment has been received. the following describes the sequence of events between the host and the flex decoder required to handle a fragmented message: ? the host will receive a vector indicating one of the following types: v 2 v 1 v 0 type 0 0 0 secure 1 0 1 alphanumeric 1 1 0 hex / binary ? the flex decoder will increment the all frame mode counter inside the flex decoder and begin to decode all of the following frames. ? the host will receive the message packet(s) contained within that frame followed by a status packet. the host must decide based on the message packet to return to normal decoding operation. if the message is indicated as fragmented by the message continued flag ??being set in the message packet then the host does not decrement the all frame mode counter at this time. the host decrements the counter if the message continued flag ??is clear by writing the all frame mode packet to the flex decoder with the ?af?bit = 1. if no other fragments, temporary addresses are pending and the faf bit is clear in the all frame mode register, then the flex decoder returns to normal operation. ? the flex decoder continues to decode all of the frames and passes any address infor-mation, vector information and message information to the host followed by a status packet indicating the end of the frame. if the message is indicated as fragmented by the message continued flag ??in the message packet then the host remains in the receive mode expecting more information from the flex decoder. ? after the host receives the second and subsequent fragment with the message continued flag ??= 1, it should decrement the all frame mode counter by sending an all frame mode packet to the flex decoder with the ?af?bit = 1. alternatively, the host may choose to decrement the counter at the end of the entire message by decrementing the counter once for each fragment received. ? when the host receives a message packet with the message continued flag ??= 0, it will send two all frame mode packets to the flex decoder with the ?af?bit = 1. the two
381 packets decrement the count for the first fragment and the last fragment. this dec-rements the all frame counter to zero, if no other fragmented messages, temporary addresses are pending and the faf bit is clear in the all frame mode register, the flex decoder returns to normal operation. ? the above process must be repeated for each occurrence of a fragmented message. the host must keep track of the number of fragmented messages being decoded and insure the all frame mode counter decrements after each fragment or after each fragmented message. table 12-32 alphanumeric message without fragmentation packet packet type phase all frame counter comment 1st address 1 a 0 address 1 is received 2nd vector 1 a 1 vector = alphanumeric type 3rd message a 1 message word received c bit = 0, no more fragments are expected. 4th variable * 0 host writes all frame mode packet to the flex decoder with the daf bit = 1 note: * host initiated packet. the flex decoder returns a packet according to 12.4, decoder- to-host packet descriptions.
382 table 12-33 alphanumeric message with fragmentation packet packet type phase all frame counter comment 1st address 1 a 0 address 1 is received 2nd vector 1 a 1 vector = alphanumeric type 3rd message a 1 message word received c bit = 1, message is fragmented, more expected 4th status 1 end of frame indication (eof = 1) 5th address 1 b 1 address 1 is received 6th vector 1 b 2 vector = alphanumeric type 7th message b 2 message word received c bit = 1, message is fragmented, more expected. 8th variable * 1 host writes all frame mode packet to the flex decoder with the daf bit = 1 9th status 1 end of frame indication (eof = 1) 10th address 1 a 1 address 1 is received 11th vector 1 a 2 vector = alphanumeric type 12th message a 2 message word received c bit = 0, no more fragments are expected. 13th variable * 1 host writes all frame mode packet to the flex decoder with the daf bit = 1 14th variable * 0 host writes all frame mode packet to the flex decoder with the daf bit = 1 note: * host initiated packet. the flex decoder returns a packet according to 12.4, decoder- to-host packet descriptions. 12.5.4 operation of a temporary address 1. group messaging the flex protocol allows for a dynamic group call for the purpose of sending a common message to a group of paging devices. the dynamic group call approach assigns a ?emporary address?using the personal address and the short instruction vector. the flex protocol specifies sixteen addresses for the dynamic group call which may be temporarily activated in a future frame (if the frame or one of the frames designated is equal to the present frame the host is to interpret this as the next occurrence of this frame 4 minutes in the future.) the temporary address is valid for one message starting in the specified frame(s) and remaining valid throughout the following frames to the completion of the message. if the message is not found in the specified frame(s) the host must disable the assigned temporary address.
383 the following describes the sequence of events between the host and the flex decoder required to handle a temporary address: ? following an address packet, the host will receive a vector packet with v 2 v 1 v 0 = 001 and i 2 i 1 i 0 = 000 or 010 (a short instruction vector indicating a temporary address has been assigned to this pager). the system may send either and i 2 i 1 i 0 = 000 or and i 2 i 1 i 0 = 010 or both when assigning a temporary address. the vector packet with and i 2 i 1 i 0 = 000 will indicate which temporary address is assigned and the frame in which the temporary address is expected. the vector packet with and i 2 i 1 i 0 = 010 will indicate which temporary address is assigned, the msb of the expected frame (essentially indicating 64 frames in which to look for the temporary address), and a message sequence number. when the vector packet with and i 2 i 1 i 0 = 010 is received on a long address, the specific assign frame is included in the mes-sage word sent after the vector. ? the flex decoder will increment the corresponding temporary address counter for each temporary address assignment vector received and begin to decode all of the follow-ing frames. note that this implies a single dynamic group assignment that is implemented by sending two short instructions (one for each temporary address assignment mode of the short instruction vector) will cause the corresponding temporary address counter to incre-ment twice. ? the flex decoder continues to decode all of the frames and passes any address infor-mation, vector information and message information to the host followed by a status packet indicating the end of each frame and the current frame number. there are several scenarios which may occur with temporary addresses. 1. the temporary address is not found in the any of the assigned frames and therefore the host must terminate the temporary address mode by sending an all frame mode packet to the flex decoder with the ?ta?bit of the particular temporary address set (if both temporary address assignment packets were used to assign the temporary address, the ?ta?bit must be set twice to disable the temporary address). 2. the temporary address is found in the frame it was assigned and was not a fragmented message. again, the host must terminate the temporary address mode by sending an all frame mode packet to the flex decoder with the ?ta?bit of the particular temporary address set (if both temporary address assignment packets were used to assign the temporary address, the ?ta?bit must be set twice to disable the temporary address). 3. the temporary address is found in the assigned frame and it is a fragmented message. in this case, the host must follow the rules for operation of a fragmented message and determine the proper time to stop the all frame mode operation. in this case, the host must write to the ?af?bit with a ??and the appropriate ?ta?bit with a ??in the all frame mode register in order to terminate both the fragmented message and the temporary address (if both temporary address assignment packets were used to assign the temporary address, the ?ta?bit must be set twice to disable the temporary address).
384 ? the above operation is repeated for every temporary address. 12.5.5 using the receiver shutdown packet the contents of this section apply to the flex roaming decoder. they are not applicable to the flex non-roaming decoder. 1. calculating time left the receiver shutdown packet gives timing information to the host. two times are of particular interest when implementing a roaming algorithm. ? timetowarmupstart. defined as the amount of time there is before the receiver will start to warm up (i.e. transition from the off state to the first warm up state). ? timetotasksdisabled. defined as the amount of time the host has to complete any host initiated tasks (e.g. by setting snd or sas in the roaming control packet). the formula? for calculating these times depend on whether the flex decoder is in synchronous mode or asynchronous mode. synchronous mode: timetowarmupstart 80ms) + (skippedframes 1874.375ms) + receiverofftime 167.5ms timetotasksdisabled 80ms) + (skippedframes 1874.375ms) 247.5ms asynchronous mode: timetowarmupstart 2) 80ms) + receiverofftime timetotasksdisabled 3) 80 ms) where, tnf: time to next frame. value from the receiver shutdown packet. skippedframes: the number of frames that won? be decoded. this can be calculated from the current frame (cf) and next needed frame (naf) fields in the receiver shutdown packet (e.g. if cf is 10 and naf is 12, then skippedframes is 1) receiverofftime: the time programmed in the receiver off setting packet.
385 2. calculating how long tasks take since the timetotaskdisabled discussed in the previous section limits how much the host can do while the flex decoder is battery saving, it is necessary for the host to know how long it can take the flex decoder to perform a task. the formulas below calculate how long the two types of host initiated tasks take to complete as measured from the last spi clock of the packet that initiates the task to the time the receiver shutdown sequence starts. note that the receiver shutdown sequence must start before tasks are disabled. the following formula calculates how long it will take to complete a noise detect started by setting the snd bit in the roaming control packet. this formula assumes that (1) the noise detect was performed while in synchronous mode or (2) the noise detect was performed in asynchronous mode and did not find flex signal or (3) the noise detect found flex signal but the das bit of the roaming control packet was set. timetoperformnoisedetect where, totalwarmuptime: the sum of the times programmed for the used warm up steps plus the time programmed for the 3200sps sync setting in the receiver control configuration packets. the following formula calculates how long it will take to complete an a-word search initiated by setting the sas bit in the roaming control packet. this formula assumes that the a-word search failed to find roaming flex channel. timetoperformawordsearch where, totalwarmuptime: the sum of the times programmed for the used warm up steps plus the time programmed for the 3200sps sync setting in the receiver control configuration packets. ast: the value configured using the timing control packet. the following formula calculates how long it will take to complete a noise detect/a-word search combination. this can occur when the noise detect is performed while in asynchronous mode, the noise detect finds flex signal, and the das bit of the roaming control packet is not set. timetoperformboth where,
386 totalwarmuptime: the sum of the times programmed for the used warm up steps plus the time programmed for the 3200sps sync setting in the receiver control configuration packets. ast: the value configured using the timing control packet.
387 12.6 timing diagrams (reference data) the following diagrams show the timing in a standalone flex decoder ic. they do not apply to this lsi, and should be used only for reference. 12.6.1 spi timing the following diagram and table describe the timing specifications of the spi interface. ready ss figure 12-13 spi timing
388 table 12-34 spi timing (vdd = 1.8 v to 3.6 v, ta = -20? to 75?) characteristic conditions symbol min * 1 max * 1 unit operating frequency f op dc 1 mhz cycle time t cyc 1000 ns select lead time t lead1 200 ns de-select lag time t lag1 200 ns select-to-ready time previous packet did not program an address word * 2 c l =50pf t rdy 80 * 2 c l =50pf t rdy 420 * 3 c l =50pf t rs 30
389 12.6.2 start-up timing the following diagram and table describe the timing specifications of the flex decoder when power is applied. vdd t start t reset t rhrl oscillator reset ready figure 12-14 start-up timing table 12-35 start-up timing (v dd = 1.8 v to 3.6 v, t a = -20? to 75?) characteristic conditions symbol min * 1 max * 1 unit oscillator start-up time t start 5 sec reset hold time t reset 200 ns reset high to ready low t rhrl 76,800 76,800 t * 2 notes: 1. the specifications given in this data sheet indicate the minimum performance level of all manufacturers of the flex decoder. individual manufacturers may have better performance than indicated. 2. t is one period of the dec clock source. note that from power-up, the oscillator start-up time can impact the availability and period of clock strobes. this can affect the actual reset high to ready low timing.
390 12.6.3 reset timing the following diagram and table describe the timing specifications of the flex decoder when it is reset. t rlrh t rl reset ready t rhrl figure 12-15 reset timing table 12-36 reset timing (v dd = 1.8 v to 3.6 v, t a = -20? to 75?) characteristic conditions symbol min * 1 max * 1 unit reset pulse width t rl 200 ns reset low to ready high t rlrh 200 ns reset high to ready low t rhrl 76,800 76,800 t * 2 notes: 1. the specifications given in this data sheet indicate the minimum performance level of all manufacturers of the flex decoder. individual manufacturers may have better performance than indicated. 2. t is one period of the dec clock source.
391 section 13 electrical characteristics 13.1 absolute maximum ratings table 13-1 lists the absolute maximum ratings. table 13-1 absolute maximum ratings item symbol value unit power supply voltage v cc ?.3 to +7.0 v analog power supply voltage av cc ?.3 to +7.0 v programming voltage v pp ?.3 to +13.0 v input voltage ports other than port b vin ?.3 to v cc +0.3 v port b avin ?.3 to av cc +0.3 v operating temperature topr ?0 to +75 ? storage temperature tstg ?5 to +125 ? note: permanent damage may occur to the chip if maximum ratings are exceeded. normal operation should be under the conditions specified in electrical characteristics. exceeding these values can result in incorrect operation and reduced reliability.
392 13.2 electrical characteristics 13.2.1 power supply voltage and operating range the power supply voltage and operating range of the h8/3937 series and h8/3937r series are indicated by the shaded region in the figures. 1. power supply voltage and oscillator frequency range 10.0 4.0 2.0 1.8 2.7 3.6 v cc (v) f osc (mhz) active (high-speed) mode sleep (high-speed) mode note: f osc is the frequency when an oscillator element or external clock is used. all operating modes 160 76.8 1.8 3.6 v cc (v) f w (khz)
393 2. power supply voltage and operating frequency range 5.0 2.0 1.0 1.8 2.7 3.6 v cc (v) (mhz) 625 250 15.625 1.8 2.7 3.6 v cc (v) (khz) 40 19.2 20 9.6 10 4.8 1.8 3.6 v cc (v) sub (khz) active (high-speed) mode sleep (high-speed) mode (except cpu) active (medium-speed) mode (except a/d converter) sleep (medium-speed) mode (except a/d converter) subactive mode subsleep mode (except cpu) watch mode (except cpu) 3. analog power supply voltage and a/d converter operating range 5.0 1.0 1.8 2.7 3.6 av cc (v) (mhz) 625 500 1.8 3.6 av cc (v) (khz) 2.7 active (medium-speed) mode sleep (medium-speed) mode active (high-speed) mode sleep (high-speed) mode
394 13.2.2 dc characteristics table 13-2 lists the dc characteristics of the h8/3937 series and h8/3937r series. table 13-2 dc characteristics v cc = 1.8 v to 3.6 v, av cc = 1.8 v to 3.6 v, v ss = av ss = 0.0 v, ta = ?0? to +75? (including subactive mode) unless otherwise indicated. values item symbol applicable pins min typ max unit test condition notes input high voltage v ih res wkp wkp irq irq adtrg v cc + 0.3 v rxd 31 , rxd 32 , ud 0.8 v cc v cc + 0.3 v osc 1 0.9 v cc v cc + 0.3 v dx 1 0.9 v cc v cc + 0.3 v p1 0 to p1 7 , p3 0 to p3 7 , p4 0 to p4 2 , p5 0 to p5 7 , p6 0 to p6 7 , p7 0 to p7 7 , p8 0 to p8 7 , p9 0 to p9 3 , pa 0 to pa 3 0.8 v cc v cc + 0.3 v pb 0 to pb 7 0.8 v cc av cc + 0.3 v ifin 0.9 v cc v cc + 0.3 v exts0, exts1, lobat 0.8 v cc v cc + 0.3 v input low voltage v il res wkp wkp irq irq adtrg 0.3 0.1 v cc v rxd 31 , rxd 32 , ud 0.3 0.2 v cc v osc 1 0.3 0.1 v cc v dx 1 0.3 0.1 v cc v p1 0 to p1 7 , p3 0 to p3 7 , p4 0 to p4 2 , p5 0 to p5 7 , p6 0 to p6 7 , p7 0 to p7 7 , p8 0 to p8 7 , p9 0 to p9 3 , pa 0 to pa 3 0.3 0.2 v cc v pb 0 to pb 7 0.3 0.2 v cc v ifin 0.3 0.1 v cc v exts0, exts1, lobat 0.3 0.2 v cc v note: connect the test and testd pins to v ss .
395 values item symbol applicable pins min typ max unit test condition notes output high voltage v oh p1 0 to p1 7 , p3 0 to p3 7 , p4 0 to p4 2 , p5 0 to p5 7 , p6 0 to p6 7 , p7 0 to p7 7 , p8 0 to p8 7 , p9 0 to p9 3 , pa 0 to pa 3 v cc 0.3 v i oh = 0.1 ma clkout v cc 0.5 vv cc = 2.5 v to 3.6 v i oh = 1.5 ma v cc 0.5 v i oh = 1.0 ma symlck, s0 to s7 v cc 0.5 vv cc = 2.5 v to 3.6 v i oh = 0.4 ma v cc 0.3 v i oh = 0.1 ma output low voltage v ol p1 0 to p1 7 , p3 0 to p3 7, p4 0 to p4 2 , p5 0 to p5 7 , p6 0 to p6 7 , p7 0 to p7 7 , p8 0 to p8 7 , p9 0 to p9 3 , pa 0 to pa 3 0.5 v i ol = 0.4 ma clkout 0.5 v v cc = 2.5 v to 3.6 v i ol = 1.5 ma 0.5 v i ol = 1.0 ma symclk, s0 to s7 0.5 v v cc = 2.5 v to 3.6 v i ol = 0.4 ma 0.3 v i ol = 0.1 ma input/ | i il | res 20.0 ? v in = 0.5 v to * 2 output 1.0 v cc 0.5 v * 1 leak- age current osc 1 , dx 1 , p1 0 to p1 7 , p3 0 to p3 7 , p4 0 to p4 2 , p5 0 to p5 7 , p6 0 to p6 7 , p7 0 to p7 7 , p8 0 to p8 7 , p9 0 to p9 3 , pa 0 to pa 3 1.0 ? v in = 0.5 v to v cc 0.5 v pb 0 to pb 7 1.0 v in = 0.5 v to av cc 0.5 v exts1, exts0, lobat, ifin 1.0 ? v in = 0.5 v to v cc 0.5 v pull-up mos current ip p1 0 to p1 7 , p3 0 to p3 7 , p5 0 to p5 7 , p6 0 to p6 7 10 120 v cc = 3 v, v in = 0 v input capaci- tance c in all input pins except power supply, res 15.0 pf f = 1 mhz, v in =0 v, ta = 25 c res 80.0 * 2 15.0 * 1 pb 0 to pb 7 15.0
396 values item symbol applicable pins min typ max unit test condition notes active mode current dissi- i ope1 v cc 0.8 ma active (high- speed) mode v cc = 3 v, f osc = 2 mhz * 3 * 4 refer- ence value pation i ope2 v cc 0.25 ma active (medium- speed) mode v cc = 3 v, f osc = 2 mhz, osc /128 * 3 * 4 refer- ence value sleep mode current dissi- pation i sleep v cc 0.45 ma v cc = 3 v, f osc = 2 mhz * 3 * 4 refer- ence value sub- active mode current dissi- pation i sub v cc 56 ? v cc = 2.7 v, 160-khz crystal oscillator ( sub = w /2) * 3 * 4 refer- ence value sub- sleep mode current dissi- pation i subsp v cc 30 ? v cc = 2.7 v, 160-khz crystal oscillator ( sub = w /2) * 3 * 4 refer- ence value watch mode current dissi- pation i watch v cc 18 ? v cc = 2.7 v, 160-khz crystal oscillator * 3 * 4 refer- ence value ram data retain- ing voltage v ram v cc 1.5 v * 3 * 4
397 values item symbol applicable pins min typ max unit test condition notes allow- i ol clkout 2.0 ma able output low current (per pin) all output pins except clkout 0.5 ma allow- able output low current (total) 20.0 ma allow- i oh clkout 2.0 ma able output high current (per pin) symclk, s0 to s7 0.5 ma v cc = 2.5v to 3.6v all output pins except clkout 0.2 ma allow- able output high i oh all output pins 10.0 ma notes: 1. applies to the mask rom products. 2. applies to the hd6473937 and hd6473937r. 3. pin states during current measurement. pin states during current dissipation measurement mode res pin internal state other pins oscillator pins active (high-speed) mode v cc only cpu operates, decoder stops v cc system clock oscillator: crystal active (medium- speed) mode subclock oscillator: pindx 1 = gnd sleep mode v cc only timers operate, decoder stops v cc subactive mode v cc only cpu operates, decoder stops v cc system clock oscillator: crystal subsleep mode v cc only timers operate, cpu and decoder stop v cc subclock oscillator: crystal (however, clock supply to watch mode v cc only time base operates, cpu and decoder stop v cc decoder block is stopped) 4. excludes current in pull-up mos transistors and output buffers.
398 13.2.3 ac characteristics table 13-3 lists the control signal timing, and tables 13-4 list the serial interface timing of the h8/3937 series and 3937r series. table 13-3 control signal timing v cc = 1.8 v to 3.6 v, av cc = 1.8 v to 3.6 v, v ss = av ss = 0.0 v, ta = ?0? to +75? (including subactive mode) unless otherwise indicated. applicable values reference item symbol pins min typ max unit test condition figure system clock f osc osc 1 , osc 2 2 10 mhz v cc = 2.7 v to 3.6 v oscillation frequency 2 4v cc = 1.8 v to 3.6 v osc clock ( osc ) cycle time t osc osc 1 , osc 2 100 500 ns v cc = 2.7 v to 3.6 v figure 13-1 250 500 v cc = 1.8 v to 3.6 v system clock ( )t cyc 2 128 t osc cycle time 208.3 ? subclock oscilla- tion frequency f w dx 1 , dx 2 76.8 or 160 khz watch clock ( w ) cycle time t w dx 1 , dx 2 26.0 or 12.5 ? figure 13-1 subclock ( sub ) cycle time t subcyc 2 8t w * instruction cycle time 2 t cyc t subcyc oscillation stabilization time t rc osc 1 , osc 2 20 45 ? v cc = 2.2 v to 3.6 v (in case of figure 13-8) figure 13-8 50 ms figure 13-8 dx 1 , dx 2 2.0 s external clock t cph osc 1 40 ns v cc = 2.7 v to 3.6 v figure 13-1 high width 200 v cc = 1.8 v to 3.6 v dx 1 6.51 or 3.125 ? external clock t cpl osc 1 40 ns v cc = 2.7 v to 3.6 v figure 13-1 low width 200 v cc = 1.8 v to 3.6 v dx 1 6.51 or 3.125 ?
399 applicable values reference item symbol pins min typ max unit test condition figure external clock t cpr osc 1 10 ns v cc = 2.7 v to 3.6 v figure 13-1 rise time 25 v cc = 1.8 v to 3.6 v dx 1 55.0 ns figure 13-1 external clock t cpf osc 1 10 ns v cc = 2.7 v to 3.6 v figure 13-1 fall time 25 v cc = 1.8 v to 3.6 v dx 1 55.0 ns figure 13-1 pin res res t cyc figure 13-2 input pin high width t ih irq irq wkp wkp adtrg t cyc t subcyc figure 13-3 input pin low width t il irq irq wkp wkp adtrg t cyc t subcyc figure 13-3 ud pin minimum modulation width t udh t udl ud 4 t cyc t subcyc figure 13-4 note: * selected with sa1 and sa0 of system clock control register 2 (syscr2).
400 table 13-4 serial interface (sci31, sci32) timing v cc = 1.8 v to 3.6 v, av cc = 1.8 v to 3.6 v, v ss = av ss = 0.0 v, ta = ?0? to +75? (including subactive mode) unless otherwise indicated. values reference item symbol min typ max unit test conditions figure input clock asynchronous t scyc 4 t cyc or figure 13-5 cycle synchronous 6 t subcyc input clock pulse width t sckw 0.4 0.6 t scyc figure 13-5 transmit data delay time(synchronous) t txd 1t cyc or t subcyc figure 13-6 receive data setup time (synchronous) t rxs 400.0 ns figure 13-6 receive data hold time (synchronous) t rxh 400.0 ns figure 13-6
401 13.2.4 a/d converter characteristics table 13-5 shows the a/d converter characteristics of the h8/3937 series and h8/3937r series. table 13-5 a/d converter characteristics v cc = 1.8 v to 3.6 v, v ss = av ss = 0.0 v, ta = ?0? to +75? (including subactive mode) unless otherwise indicated. applicable values item symbol pins min typ max unit test condition notes analog power supply voltage av cc av cc 1.8 3.6 v * 1 analog input voltage av in an 0 to an 7 0.3 av cc + 0.3 v analog power ai ope av cc 1.0 ma av cc = 3.0 v supply current ai stop1 av cc 600 ? * 2 reference value ai stop2 av cc 5a * 3 analog input capacitance c ain an 0 to an 7 15.0 pf allowable signal source impedance r ain 10.0 k ? 10 bit nonlinearity error ?.5 lsb av cc = 3.0 to 3.6 v v cc = 3.0 to 3.6 v ?.5 av cc = 2.0 to 3.6 v v cc = 2.0 to 3.6 v ?.5 except the above * 4 quantization error ?.5 lsb absolute accuracy ?.0 lsb av cc = 3.0 to 3.6 v v cc = 3.0 to 3.6 v ?.0 av cc = 2.0 to 3.6 v v cc = 2.0 to 3.6 v ?.0 except the above * 4 conversion time 12.4 124 ? av cc = 2.7 to 3.6 v v cc = 2.7 to 3.6 v 62 124 except the above notes: 1. set av cc = v cc when the a/d converter is not used. 2. ai stop1 is the current in active and sleep modes while the a/d converter is idle. 3. ai stop2 is the current at reset and in standby, watch, subactive, and subsleep modes while the a/d converter is idle. 4. conversion time: 62 ?
402 13.3 operation timing figures 13-1 to 13-7 show timing diagrams. t , tw osc v ih v il t cph t cpl t cpr osc1 dx 1 t cpf figure 13-1 clock input timing r es v il t rel figure 13-2 res low width v ih v il t il irq irq wkp wkp adtrg figure 13-3 input timing
403 v il v ih t udl ud t udh figure 13-4 ud pin minimum modulation width timing t scyc 31 t sckw sck 32 sck figure 13-5 sck3 input clock timing
404 32 t scyc t txd t rxs t rxh v oh v or v ih oh v or v il ol * * * v ol oh cc ol * sck 31 sck txd 31 txd 32 (transmit data) rxd 31 rxd 32 (receive data) note: * output timing reference levels output high output low load conditions are shown in figure 13-7. v = 1/2 v + 0.2 v v = 0.8 v figure 13-6 sci3 synchronous mode input/output timing
405 13.4 output load circuit v cc 2.4 k ? ? figure 13-7 output load condition 13.5 resonator equivalent circuit c s c o crystal resonator parameter r s osc 2 osc 1 l s ceramic resonator parameters frequency (mhz) r s (max) c o (max) 4.193 100 ? ? figure 13-8 resonator equivalent circuit
406 13.6 usage note the ztat and mask rom versions both satisfy the electrical characteristics shown in this manual, but actual electrical characteristic values, operating margins, noise margins, and other properties may vary due to differences in manufacturing process, on-chip rom, layout patterns, and so on. when system evaluation testing is carried out using the ztat version, the same evaluation testing should also be conducted for the mask rom version when changing over to that version.
407 appendix a cpu instruction set a.1 instructions operation notation rd8/16 general register (destination) (8 or 16 bits) rs8/16 general register (source) (8 or 16 bits) rn8/16 general register (8 or 16 bits) ccr condition code register n n (negative) flag in ccr z z (zero) flag in ccr v v (overflow) flag in ccr c c (carry) flag in ccr pc program counter sp stack pointer #xx: 3/8/16 immediate data (3, 8, or 16 bits) d: 8/16 displacement (8 or 16 bits) @aa: 8/16 absolute address (8 or 16 bits) + addition subtraction multiplication division logical and logical or exclusive logical or move logical complement condition code notation symbol modified according to the instruction result * not fixed (value not guaranteed) 0 always cleared to 0 not affected by the instruction execution result
408 table a-1 lists the h8/300l cpu instruction set. table a-1 instruction set addressing mode/ instruction length (bytes) condition code mnemonic operand size operation #xx: 8/16 rn @rn @(d:16, rn) @?n/@rn+ @aa: 8/16 @(d:8, pc) @@aa implied ihnzvc no. of states mov.b #xx:8, rd b #xx:8 rd8 2 02 mov.b rs, rd b rs8 rd8 2 02 mov.b @rs, rd b @rs16 rd8 2 04 mov.b @(d:16, rs), rd b @(d:16, rs16) rd8 4 06 mov.b @rs+, rd b @rs16 rd8 rs16+1 rs16 2 06 mov.b @aa:8, rd b @aa:8 rd8 2 04 mov.b @aa:16, rd b @aa:16 rd8 4 06 mov.b rs, @rd b rs8 @rd16 2 04 mov.b rs, @(d:16, rd) b rs8 @(d:16, rd16) 4 06 mov.b rs, @?d b rd16? rd16 rs8 @rd16 2 06 mov.b rs, @aa:8 b rs8 @aa:8 2 04 mov.b rs, @aa:16 b rs8 @aa:16 4 06 mov.w #xx:16, rd w #xx:16 rd 4 04 mov.w rs, rd w rs16 rd16 2 02 mov.w @rs, rd w @rs16 rd16 2 04 mov.w @(d:16, rs), rd w @(d:16, rs16) rd16 4 06 mov.w @rs+, rd w @rs16 rd16 rs16+2 rs16 2 06 mov.w @aa:16, rd w @aa:16 rd16 4 06 mov.w rs, @rd w rs16 @rd16 2 04 mov.w rs, @(d:16, rd) w rs16 @(d:16, rd16) 4 06 mov.w rs, @?d w rd16? rd16 rs16 @rd16 2 06 mov.w rs, @aa:16 w rs16 @aa:16 4 06 pop rd w @sp rd16 sp+2 sp 2 06 push rs w sp? sp rs16 @sp 2 06
409 addressing mode/ instruction length (bytes) condition code mnemonic operand size operation #xx: 8/16 rn @rn @(d:16, rn) @ rn/@rn+ @aa: 8/16 @(d:8, pc) @@aa implied ihnzvc no. of states add.b #xx:8, rd b rd8+#xx:8 rd8 2 2 add.b rs, rd b rd8+rs8 rd8 2 2 add.w rs, rd w rd16+rs16 rd16 2 (1) 2 addx.b #xx:8, rd b rd8+#xx:8 +c rd8 2 (2) 2 addx.b rs, rd b rd8+rs8 +c rd8 2 (2) 2 adds.w #1, rd w rd16+1 rd16 2 2 adds.w #2, rd w rd16+2 rd16 2 2 inc.b rd b rd8+1 rd8 2 ? daa.b rd b rd8 decimal adjust rd8 2 * * (3) 2 sub.b rs, rd b rd8?s8 rd8 2 2 sub.w rs, rd w rd16?s16 rd16 2 (1) 2 subx.b #xx:8, rd b rd8?xx:8 ? rd8 2 (2) 2 subx.b rs, rd b rd8?s8 ? rd8 2 (2) 2 subs.w #1, rd w rd16? rd16 2 2 subs.w #2, rd w rd16? rd16 2 2 dec.b rd b rd8? rd8 2 ? das.b rd b rd8 decimal adjust rd8 2 * * ? neg.b rd b 0?d rd 2 2 cmp.b #xx:8, rd b rd8?xx:8 2 2 cmp.b rs, rd b rd8?s8 2 2 cmp.w rs, rd w rd16?s16 2 (1) 2 mulxu.b rs, rd b rd8 rs8 rd16 2 14 divxu.b rs, rd b rd16 rs8 rd16 (rdh: remainder, rdl: quotient) 2 (5) (6) 14 and.b #xx:8, rd b rd8 #xx:8 rd8 2 02 and.b rs, rd b rd8 rs8 rd8 2 02 or.b #xx:8, rd b rd8 #xx:8 rd8 2 02 or.b rs, rd b rd8 rs8 rd8 2 02 xor.b #xx:8, rd b rd8 #xx:8 rd8 2 02 xor.b rs, rd b rd8 rs8 rd8 2 02 not.b rd b rd rd 2 02
410 addressing mode/ instruction length (bytes) condition code mnemonic operand size operation #xx: 8/16 rn @rn @(d:16, rn) @ rn/@rn+ @aa: 8/16 @(d:8, pc) @@aa implied ihnzvc no. of states shal.b rd b b 7 b 0 0 c 2 2 shar.b rd b c b 7 b 0 2 0 2 shll.b rd b b 7 b 0 0 c 2 0 2 shlr.b rd b b 7 b 0 0c 2 0 0 2 rotxl.b rd b c b 7 b 0 2 0 2 rotxr.b rd b c b 7 b 0 2 0 2 rotl.b rd b c b 7 b 0 2 0 2 rotr.b rd b c b 7 b 0 2 0 2 bset #xx:3, rd b (#xx:3 of rd8) 12 2 bset #xx:3, @rd b (#xx:3 of @rd16) 14 8 bset #xx:3, @aa:8 b (#xx:3 of @aa:8) 14 8 bset rn, rd b (rn8 of rd8) 12 2 bset rn, @rd b (rn8 of @rd16) 14 8 bset rn, @aa:8 b (rn8 of @aa:8) 14 8 bclr #xx:3, rd b (#xx:3 of rd8) 02 2 bclr #xx:3, @rd b (#xx:3 of @rd16) 04 8 bclr #xx:3, @aa:8 b (#xx:3 of @aa:8) 04 8 bclr rn, rd b (rn8 of rd8) 02 2
411 addressing mode/ instruction length (bytes) condition code mnemonic operand size operation #xx: 8/16 rn @rn @(d:16, rn) @ rn/@rn+ @aa: 8/16 @(d:8, pc) @@aa implied ihnzvc no. of states bclr rn, @rd b (rn8 of @rd16) 04 8 bclr rn, @aa:8 b (rn8 of @aa:8) 04 8 bnot #xx:3, rd b (#xx:3 of rd8) ( #xx:3 of rd8 ) 2 2 bnot #xx:3, @rd b (#xx:3 of @rd16) ( #xx:3 of @rd16 ) 4 8 bnot #xx:3, @aa:8 b (#xx:3 of @aa:8) ( #xx:3 of @aa:8 ) 4 8 bnot rn, rd b (rn8 of rd8) ( rn8 of rd8 ) 2 2 bnot rn, @rd b (rn8 of @rd16) ( rn8 of @rd16 ) 4 8 bnot rn, @aa:8 b (rn8 of @aa:8) ( rn8 of @aa:8 ) 4 8 btst #xx:3, rd b ( #xx:3 of rd8 ) z2 2 btst #xx:3, @rd b ( #xx:3 of @rd16 ) z4 6 btst #xx:3, @aa:8 b ( #xx:3 of @aa:8 ) z4 6 btst rn, rd b ( rn8 of rd8 ) z2 2 btst rn, @rd b ( rn8 of @rd16 ) z4 6 btst rn, @aa:8 b ( rn8 of @aa:8 ) z4 6 bld #xx:3, rd b (#xx:3 of rd8) c2 2 bld #xx:3, @rd b (#xx:3 of @rd16) c4 6 bld #xx:3, @aa:8 b (#xx:3 of @aa:8) c4 6 bild #xx:3, rd b ( #xx:3 of rd8 ) c2 2 bild #xx:3, @rd b ( #xx:3 of @rd16 ) c4 6 bild #xx:3, @aa:8 b ( #xx:3 of @aa:8 ) c4 6 bst #xx:3, rd b c (#xx:3 of rd8) 2 2 bst #xx:3, @rd b c (#xx:3 of @rd16) 4 8 bst #xx:3, @aa:8 b c (#xx:3 of @aa:8) 4 8 bist #xx:3, rd b c (#xx:3 of rd8) 2 2 bist #xx:3, @rd b c (#xx:3 of @rd16) 4 8 bist #xx:3, @aa:8 b c (#xx:3 of @aa:8) 4 8 band #xx:3, rd b c (#xx:3 of rd8) c2 2 band #xx:3, @rd b c (#xx:3 of @rd16) c4 6 band #xx:3, @aa:8 b c (#xx:3 of @aa:8) c4 6
412 addressing mode/ instruction length (bytes) condition code mnemonic operand size operation #xx: 8/16 rn @rn @(d:16, rn) @ rn/@rn+ @aa: 8/16 @(d:8, pc) @@aa implied ihnzvc no. of states biand #xx:3, rd b c ( #xx:3 of rd8 ) c2 2 biand #xx:3, @rd b c ( #xx:3 of @rd16 ) c4 6 biand #xx:3, @aa:8 b c ( #xx:3 of @aa:8 ) c4 6 bor #xx:3, rd b c (#xx:3 of rd8) c2 2 bor #xx:3, @rd b c (#xx:3 of @rd16) c4 6 bor #xx:3, @aa:8 b c (#xx:3 of @aa:8) c4 6 bior #xx:3, rd b c ( #xx:3 of rd8 ) c2 2 bior #xx:3, @rd b c ( #xx:3 of @rd16 ) c4 6 bior #xx:3, @aa:8 b c ( #xx:3 of @aa:8 ) c4 6 bxor #xx:3, rd b c (#xx:3 of rd8) c2 2 bxor #xx:3, @rd b c (#xx:3 of @rd16) c4 6 bxor #xx:3, @aa:8 b c (#xx:3 of @aa:8) c4 6 bixor #xx:3, rd b c ( #xx:3 of rd8 ) c2 2 bixor #xx:3, @rd b c ( #xx:3 of @rd16 ) c4 6 bixor #xx:3, @aa:8 b c ( #xx:3 of @aa:8 ) c4 6 bra d:8 (bt d:8) pc pc+d:8 2 4 brn d:8 (bf d:8) pc pc+2 2 4 bhi d:8 if condition c z = 0 2 4 bls d:8 is true then c z = 1 2 4 bcc d:8 (bhs d:8) pc pc+d:8 c = 0 2 4 bcs d:8 (blo d:8) else next; c = 1 2 4 bne d:8 z = 0 2 4 beq d:8 z = 1 2 4 bvc d:8 v = 0 2 4 bvs d:8 v = 1 2 4 bpl d:8 n = 0 2 4 bmi d:8 n = 1 2 4 bge d:8 n v = 0 2 4 blt d:8 n v = 1 2 4 bgt d:8 z (n v) = 0 2 4 ble d:8 z (n v) = 1 2 4
413 addressing mode/ instruction length (bytes) condition code mnemonic operand size operation #xx: 8/16 rn @rn @(d:16, rn) @ rn/@rn+ @aa: 8/16 @(d:8, pc) @@aa implied ihnzvc no. of states jmp @rn pc rn16 2 4 jmp @aa:16 pc aa:16 4 6 jmp @@aa:8 pc @aa:8 2 8 bsr d:8 sp 2 sp pc @sp pc pc+d:8 2 6 jsr @rn sp 2 sp pc @sp pc rn16 2 6 jsr @aa:16 sp 2 sp pc @sp pc aa:16 4 8 jsr @@aa:8 sp 2 sp pc @sp pc @aa:8 2 8 rts pc @sp sp+2 sp 2 8 rte ccr @sp sp+2 sp pc @sp sp+2 sp 2 10 sleep transit to sleep mode. 2 2 ldc #xx:8, ccr b #xx:8 ccr 2 2 ldc rs, ccr b rs8 ccr 2 2 stc ccr, rd b ccr rd8 2 2 andc #xx:8, ccr b ccr #xx:8 ccr 2 2 orc #xx:8, ccr b ccr #xx:8 ccr 2 2 xorc #xx:8, ccr b ccr #xx:8 ccr 2 2 nop pc pc+2 2 2 eepmov if r4l 0 repeat @r5 @r6 r5+1 r5 r6+1 r6 r4l 1 r4l until r4l=0 else next; 4 (4)
414 notes: (1) set to 1 when there is a carry or borrow from bit 11; otherwise cleared to 0. (2) if the result is zero, the previous value of the flag is retained; otherwise the flag is cleared to 0. (3) set to 1 if decimal adjustment produces a carry; otherwise retains value prior to arithmetic operation. (4) the number of states required for execution is 4n + 9 (n = value of r4l). (5) set to 1 if the divisor is negative; otherwise cleared to 0. (6) set to 1 if the divisor is zero; otherwise cleared to 0.
415 a.2 operation code map table a-2 is an operation code map. it shows the operation codes contained in the first byte of the instruction code (bits 15 to 8 of the first instruction word). instruction when first bit of byte 2 (bit 7 of first instruction word) is 0. instruction when first bit of byte 2 (bit 7 of first instruction word) is 1.
416 table a-2 operation code map high low 0123456789abcdef 0 1 2 3 4 5 6 7 8 9 a b c d e f nop bra mulxu bset shll shal sleep brn divxu bnot shlr shar stc bhi bclr rotxl rotl ldc bls btst rotxr rotr orc or bcc rts xorc xor bcs bsr bor bior bxor bixor band biand andc and bne rte ldc beq not neg bld bild bst bist add sub bvc bvs mov inc dec bpl jmp adds subs bmi eepmov mov cmp bge blt addx subx bgt jsr daa das ble mov add addx cmp subx or xor and mov mov * note: bit-manipulation instructions the push and pop instructions are identical in machine language to mov instructions. *
417 a.3 number of execution states the tables here can be used to calculate the number of states required for instruction execution. table a-4 indicates the number of states required for each cycle (instruction fetch, read/write, etc.), and table a-3 indicates the number of cycles of each type occurring in each instruction. the total number of states required for execution of an instruction can be calculated from these two tables as follows: execution states = i s i + j s j + k s k + l s l + m s m + n s n examples: when instruction is fetched from on-chip rom, and an on-chip ram is accessed. bset #0, @ff00 from table a-4: i = l = 2, j = k = m = n= 0 from table a-3: s i = 2, s l = 2 number of states required for execution = 2 2 + 2 2 = 8 when instruction is fetched from on-chip rom, branch address is read from on-chip rom, and on-chip ram is used for stack area. jsr @@ 30 from table a-4: i = 2, j = k = 1, l = m = n = 0 from table a-3: s i = s j = s k = 2 number of states required for execution = 2 2 + 1 2+ 1 2 = 8 table a-3 number of cycles in each instruction execution status access location (instruction cycle) on-chip memory on-chip peripheral module instruction fetch s i 2 branch address read s j stack operation s k byte data access s l 2 or 3 * word data access s m internal operation s n 11 note: * depends on which on-chip module is accessed. see 2.9.1, notes on data access for details.
418 table a-4 number of cycles in each instruction instruc- tion mnemonic instruction fetch i branch addr. read j stack operation k byte data access l word data access m internal operation n add add.b #xx:8, rd 1 add.b rs, rd 1 add.w rs, rd 1 adds adds.w #1, rd 1 adds.w #2, rd 1 addx addx.b #xx:8, rd 1 addx.b rs, rd 1 and and.b #xx:8, rd 1 and.b rs, rd 1 andc andc #xx:8, ccr 1 band band #xx:3, rd 1 band #xx:3, @rd 2 1 band #xx:3, @aa:8 2 1 bcc bra d:8 (bt d:8) 2 brn d:8 (bf d:8) 2 bhi d:8 2 bls d:8 2 bcc d:8 (bhs d:8) 2 bcs d:8 (blo d:8) 2 bne d:8 2 beq d:8 2 bvc d:8 2 bvs d:8 2 bpl d:8 2 bmi d:8 2 bge d:8 2 blt d:8 2 bgt d:8 2 ble d:8 2 bclr bclr #xx:3, rd 1 bclr #xx:3, @rd 2 2 bclr #xx:3, @aa: 8 2 2 bclr rn, rd 1 bclr rn, @rd 2 2 bclr rn, @aa:8 2 2
419 instruc- tion mnemonic instruction fetch i branch addr. read j stack operation k byte data access l word data access m internal operation n biand biand #xx:3, rd 1 biand #xx:3, @rd 2 1 biand #xx:3, @aa:8 2 1 bild bild #xx:3, rd 1 bild #xx:3, @rd 2 1 bild #xx:3, @aa:8 2 1 bior bior #xx:3, rd 1 bior #xx:3, @rd 2 1 bior #xx:3, @aa:8 2 1 bist bist #xx:3, rd 1 bist #xx:3, @rd 2 2 bist #xx:3, @aa:8 2 2 bixor bixor #xx:3, rd 1 bixor #xx:3, @rd 2 1 bixor #xx:3, @aa:8 2 1 bld bld #xx:3, rd 1 bld #xx:3, @rd 2 1 bld #xx:3, @aa:8 2 1 bnot bnot #xx:3, rd 1 bnot #xx:3, @rd 2 2 bnot #xx:3, @aa:8 2 2 bnot rn, rd 1 bnot rn, @rd 2 2 bnot rn, @aa:8 2 2 bor bor #xx:3, rd 1 bor #xx:3, @rd 2 1 bor #xx:3, @aa:8 2 1 bset bset #xx:3, rd 1 bset #xx:3, @rd 2 2 bset #xx:3, @aa:8 2 2 bset rn, rd 1 bset rn, @rd 2 2 bset rn, @aa:8 2 2 bsr bsr d:8 2 1 bst bst #xx:3, rd 1 bst #xx:3, @rd 2 2 bst #xx:3, @aa:8 2 2
420 instruc- tion mnemonic instruction fetch i branch addr. read j stack operation k byte data access l word data access m internal operation n btst btst #xx:3, rd 1 btst #xx:3, @rd 2 1 btst #xx:3, @aa:8 2 1 btst rn, rd 1 btst rn, @rd 2 1 btst rn, @aa:8 2 1 bxor bxor #xx:3, rd 1 bxor #xx:3, @rd 2 1 bxor #xx:3, @aa:8 2 1 cmp cmp. b #xx:8, rd 1 cmp. b rs, rd 1 cmp.w rs, rd 1 daa daa.b rd 1 das das.b rd 1 dec dec.b rd 1 divxu divxu.b rs, rd 1 12 eepmov eepmov 2 2n+2 * 1 inc inc.b rd 1 jmp jmp @rn 2 jmp @aa:16 2 2 jmp @@aa:8 2 1 2 jsr jsr @rn 2 1 jsr @aa:16 2 1 2 jsr @@aa:8 2 1 1 ldc ldc #xx:8, ccr 1 ldc rs, ccr 1 mov mov.b #xx:8, rd 1 mov.b rs, rd 1 mov.b @rs, rd 1 1 mov.b @(d:16, rs), rd 21 mov.b @rs+, rd 1 1 2 mov.b @aa:8, rd 1 1 mov.b @aa:16, rd 2 1 mov.b rs, @rd 1 1 note: * n: initial value in r4l. the source and destination operands are accessed n + 1 times each.
421 instruc- tion mnemonic instruction fetch i branch addr. read j stack operation k byte data access l word data access m internal operation n mov mov.b rs, @(d:16, rd) 21 mov.b rs, @ rd 1 1 2 mov.b rs, @aa:8 1 1 mov.b rs, @aa:16 2 1 mov.w #xx:16, rd 2 mov.w rs, rd 1 mov.w @rs, rd 1 1 mov.w @(d:16, rs), rd 21 mov.w @rs+, rd 1 1 2 mov.w @aa:16, rd 2 1 mov.w rs, @rd 1 1 mov.w rs, @(d:16, rd) 21 mov.w rs, @ rd 1 1 2 mov.w rs, @aa:16 2 1 mulxu mulxu.b rs, rd 1 12 neg neg.b rd 1 nop nop 1 not not.b rd 1 or or.b #xx:8, rd 1 or.b rs, rd 1 orc orc #xx:8, ccr 1 rotl rotl.b rd 1 rotr rotr.b rd 1 rotxl rotxl.b rd 1 rotxr rotxr.b rd 1 rte rte 2 2 2 rts rts 2 1 2 shal shal.b rd 1 shar shar.b rd 1 shll shll.b rd 1 shlr shlr.b rd 1 sleep sleep 1 stc stc ccr, rd 1
422 instruc- tion mnemonic instruction fetch i branch addr. read j stack operation k byte data access l word data access m internal operation n sub sub.b rs, rd 1 sub.w rs, rd 1 sub sub.b rs, rd 1 sub.w rs, rd 1 subs subs.w #1, rd 1 subs.w #2, rd 1 pop pop rd 1 1 2 push push rs 1 1 2 subx subx.b #xx:8, rd 1 subx.b rs, rd 1 xor xor.b #xx:8, rd 1 xor.b rs, rd 1 xorc xorc #xx:8, ccr 1
423 appendix b internal i/o registers b.1 addresses lower register bit names module address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 name h'90 wegr wkegs7 wkegs6 wkegs5 wkegs4 wkegs3 wkegs2 wkegs1 wkegs0 system control h'91 spcr spc32 spc31 scinv3 scinv2 scinv1 scinv0 sci h'92 cwosr cwos timer a h'93 h'94 h'95 h'96 h'97 h'98 smr31 com31 chr31 pe31 pm31 stop31 mp31 cks311 cks310 sci31 h'99 brr31 brr317 brr316 brr315 brr314 brr313 brr312 brr311 brr310 h'9a scr31 tie31 rie31 te31 re31 mpie31 teie31 cke31 cke310 h'9b tdr31 tdr317 tdr316 tdr315 tdr314 tdr313 tdr312 tdr311 tdr310 h'9c ssr31 tdre31 rdrf31 oer31 fer31 per31 tend31 mpbr31 mpbt31 h'9d rdr31 rdr317 rdr316 rdr315 rdr314 rdr313 rdr312 rdr311 rdr310 h'9e h'9f h'a0 scr1 snc1 snc0 mrkon ltch cks3 cks2 cks1 cks0 sci1 h'a1 scsr1 sol orer mtrf stf h'a2 sdru sdru7 sdru6 sdru5 sdru4 sdru3 sdru2 sdru1 sdru0 h'a3 sdrl sdrl7 sdrl6 sdrl5 sdrl4 sdrl3 sdrl2 sdrl1 sdrl0 h'a4 h'a5 h'a6 h'a7 h'a8 smr32 com32 chr32 pe32 pm32 stop32 mp32 cks321 cks320 sci32 h'a9 brr32 brr327 brr326 brr325 brr324 br323 brr322 brr321 brr320 h'aa scr32 tie32 rie32 te32 re32 mpie32 teie32 cke321 cke320 h'ab tdr32 tdr327 tdr326 tdr325 tdr324 tdr323 tdr322 tdr321 tdr320 h'ac ssr32 tdre32 rdrf32 oer32 fer32 per32 tend32 mpbr32 mpbt32 h'ad rdr32 rdr327 rdr326 rdr325 rdr324 rdr323 rdr322 rdr321 rdr320 h'ae h'af h'b0 tma tma7 tma6 tma5 tma3 tma2 tma1 tma0 timer a h'b1 tca tca7 tca6 tca5 tca4 tca3 tca2 tca1 tca0
424 lower register bit names module address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 name h'b2 tcsrw b6wi tcwe b4wi tcsrwe b2wi wdon bow1 wrst watchdog h'b3 tcw tcw7 tcw6 tcw5 tcw4 tcw3 tcw2 tcw1 tcwo timer h'b4 tmc tmc7 tmc6 tmc5 tmc2 tmc1 tmc0 timer c h'b5 tcc/ tlc tcc/ tlc7 tcc6/ tlc6 tcc5/ tlc5 tcc4/ tlc4 tcc3/ tlc3 tcc2/ tlc2 tcc1/ tlc1 tcc0/ tlc0 h'b6 tcrf tolh cksh2 cksh1 cksh0 toll cksl2 cksl1 cksl0 timer f h'b7 tcsrf ovfh cmfh ovieh cclrh ovfl cmfl oviel cclrl h'b8 tcfh tcfh7 tcfh6 tcfh5 tcfh4 tcfh3 tcfh2 tcfh1 tcfh0 h'b9 tcfl tcfl7 tcfl6 tcfl5 tcfl4 tcfl3 tcfl2 tcfl1 tcfl0 h'ba ocrfh ocrfh7 ocrfh6 ocrfh5 ocrfh4 ocrfh3 ocrfh2 ocrfh1 ocrfh0 h'bb ocrfl ocrfl7 ocrfl6 ocrfl5 ocrfl4 ocrfl3 ocrfl2 ocrfl1 ocrfl0 h'bc tmg ovfh ovfl ovie iiegs cclr1 cclr0 cks1 cks0 timer g h'bd icrgf icrgf7 icrgf6 icrgf5 icrgf4 icrgf3 icrgf2 icrgf1 icrgfo h'be icrgr icrgr7 icrgr6 icrgr5 icrgr4 icrgr3 icrgr2 icrgr1 icrgro h'bf h'c0 h'c1 h'c2 h'c3 h'c4 adrrh adr9 adr8 adr7 adr6 adr5 adr4 adr3 adr2 a/d h'c5 adrrl adr1 adr0 converter h'c6 amr cks trge ch3 ch2 ch1 ch0 h'c7 adsr adsf h'c8 pmr1 irq3 irq2 irq1 irq4 tmig tmofh tmofl tmow i/o port h'c9 pmr2 pof1 so1 si1 sck1 h'ca pmr3 wdcks ncs irq0 reso ud h'cb pmr4 nmod7 nmod6 nmod5 nmod4 nmod3 nmod2 nmod1 nmod0 h'cc pmr5 wkp7 wkp6 wkp5 wkp4 wkp3 wkp2 wkp1 wkp0 h'cd h'ce h'cf h'd0 h'd1 h'd2 h'd3 h'd4 pdr1 p1 7 p1 6 p1 5 p1 4 p1 3 p1 2 p1 1 p1 0 i/o port h'd5 pdr2 p2 4 p2 3 p2 2 p2 1 p2 0 h'd6 pdr3 p3 7 p3 6 p3 5 p3 4 p3 3 p3 2 p3 1 p3 0 h'd7 pdr4 p4 3 p4 2 p4 1 p4 0 h'd8 pdr5 p5 7 p5 6 p5 5 p5 4 p5 3 p5 2 p5 1 p5 0
425 lower register bit names module address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 name h'd9 pdr6 p6 7 p6 6 p6 5 p6 4 p6 3 p6 2 p6 1 p6 0 i/o port h'da pdr7 p7 7 p7 6 p7 5 p7 4 p7 3 p7 2 p7 1 p7 0 h'db pdr8 p8 7 p8 6 p8 5 p8 4 p8 3 p8 2 p8 1 p8 0 h'dc pdr9 p9 3 p9 2 p9 1 p9 0 h'dd pdra pa 3 pa 2 pa 1 pa 0 h'de pdrb pb 7 pb 6 pb 5 pb 4 pb 3 pb 2 pb 1 pb 0 h'df h'e0 pucr1 pucr1 7 pucr1 6 pucr1 5 pucr1 4 pucr1 3 pucr1 2 pucr1 1 pucr1 0 i/o port h'e1 pucr3 pucr3 7 pucr3 6 pucr3 5 pucr3 4 pucr3 3 pucr3 2 pucr3 1 pucr3 0 h'e2 pucr5 pucr5 7 pucr5 6 pucr5 5 pucr5 4 pucr5 3 pucr5 2 pucr5 1 pucr5 0 h'e3 pucr6 pucr6 7 pucr6 6 pucr6 5 pucr6 4 pucr6 3 pucr6 2 pucr6 1 pucr6 0 h'e4 pcr1 pcr1 7 pcr1 6 pcr1 5 pcr1 4 pcr1 3 pcr1 2 pcr1 1 pcr1 0 h'e5 pcr2 pcr2 4 pcr2 3 pcr2 2 pcr2 1 pcr2 0 h'e6 pcr3 pcr3 7 pcr3 6 pcr3 5 pcr3 4 pcr3 3 pcr3 2 pcr3 1 pcr3 0 h'e7 pcr4 pcr4 2 pcr4 1 pcr4 0 h'e8 pcr5 pcr5 7 pcr5 6 pcr5 5 pcr5 4 pcr5 3 pcr5 2 pcr5 1 pcr5 0 h'e9 pcr6 pcr6 7 pcr6 6 pcr6 5 pcr6 4 pcr6 3 pcr6 2 pcr6 1 pcr6 0 h'ea pcr7 pcr7 7 pcr7 6 pcr7 5 pcr7 4 pcr7 3 pcr7 2 pcr7 1 pcr7 0 h'eb pcr8 pcr8 7 pcr8 6 pcr8 5 pcr8 4 pcr8 3 pcr8 2 pcr8 1 pcr8 0 h'ec pcr9 pcr9 3 pcr9 2 pcr9 1 pcr9 0 h'ed pcra pcra 3 pcra 2 pcra 1 pcra 0 h'ee h'ef h'f0 syscr1 ssby sts2 sts1 sts0 lson ma1 ma0 system h'f1 syscr2 nesel dton mson sa1 sa0 control h'f2 iegr ieg4 ieg3 ieg2 ieg1 ieg0 h'f3 ienr1 ienta iens1 ienwp ien4 ien3 ien2 ien1 ien0 h'f4 ienr2 iendt ienad ientg ientfh ientfl ientc h'f5 h'f6 irr1 irrta irrs1 irri4 irri3 irri2 irri1 irri0 h'f7 irri2 irrdt irrad irrtg irrtfh irrtfl irrtc h'f8 h'f9 iwpr iwpf7 iwpf6 iwpf5 iwpf4 iwpf3 iwpf2 iwpf1 iwpf0 h'fa ck stp r1 s1ckstp s31ckstp s32ckstp a dc k s tp t g ck s tp tfckstp tcck s tp ta ck s tp h'fb ck stp r2 wdckstp h'fc h'fd h'fe h'ff legend sci: serial communication interface
426 b.2 functions tmc?imer mode register c h'b4 timer c register name address to which the register is mapped name of on-chip supporting module register acronym bit numbers initial bit values names of the bits. dashes ( ) indicate reserved bits. full name of bit descriptions of bit settings read only write only read and write r w r/w possible types of access bit initial value read/write 7 tmc7 0 r/w 6 tmc6 0 r/w 5 tmc5 0 r/w 3 1 0 tmc0 0 r/w 2 tmc2 0 r/w 1 tmc1 0 r/w 4 1 clock select 0 internal clock: internal clock: 0 0 1 internal clock: internal clock: 10 1 1 00 1 10 1 internal clock: internal clock: internal clock: external event (tmic): /8192 /2048 /512 /64 /16 /4 /4 rising or falling edge w counter up/down control tcc is an up-counter tcc is a down-counter 0 0 1 tcc up/down control is determined by input at pin ud. tcc is a down-counter if the ud input is high, and an up-counter if the ud input is low. 1 * auto-reload function select interval timer function selected * : don t care auto-reload function selected 0 1
427 wegr?akeup edge select register h'90 system control bit initial value read/write 7 wkegs7 0 r/w 6 wkegs6 0 r/w 5 wkegs5 0 r/w 0 wkegs0 0 r/w 2 wkegs2 0 r/w 1 wkegs1 0 r/w 4 wkegs4 0 r/w wkpn edge selected 0 wkpn pin falling edge detected (n = 0 to 7) 1 wkpn pin rising edge detected 3 wkegs3 0 r/w spcr?erial port control register h'91 sci bit initial value read/write 7 1 6 1 5 spc32 0 r/w 0 scinv0 0 r/w 2 scinv2 0 r/w 1 scinv1 0 r/w 4 spc31 0 r/w rxd 31 pin input data inversion switch 0 rxd 31 input data is not inverted 1 rxd 31 input data is inverted txd 31 pin output data inversion switch 0 txd 31 output data is not inverted 1 txd 31 output data is inverted rxd 32 pin input data inversion switch 0 rxd 32 input data is not inverted 1 rxd 32 input data is inverted txd 32 pin output data inversion switch 0 txd 32 output data is not inverted 1 txd 32 output data is inverted p3 5 txd 31 pin function switch 0 functions as p3 5 i/o pin 1 functions as txd 31 output pin p4 2 /txd 32 pin function switch 0 function as p4 2 i/o pin 1 function as txd 32 output pin 3 scinv3 0 r/w
428 cwosr?ubclock output select register h'92 timer a bit initial value read/write 7 1 6 1 5 1 0 cwos 0 r/w 2 1 1 1 4 1 tmow pin clock select 0 clock output from tma is output 1 w is output 3 1
429 smr31?erial mode register 31 h'98 sci31 bit initial value read/write 7 com31 0 r/w 6 chr31 0 r/w 5 pe31 0 r/w 0 cks310 0 r/w 2 mp31 0 r/w 1 cks311 0 r/w 4 pm31 0 r/w clock select 0 0 01 1 1 1 clock w/2 clock/ w clock 0 /16 clock /64 clock multiprocessor mode 0 multiprocessor communication function disabled 1 multiprocessor communication function enabled stop bit length 0 1 stop bit 1 2 stop bits parity mode 0 even parity 1 odd parity parity enable 0 parity bit addition and checking disabled 1 parity bit addition and checking enabled character length 0 8-bit data/5-bit data 1 7-bit data/5-bit data communication mode 0 asynchronous mode 1 synchronous mode 3 stop31 0 r/w
430 brr31?it rate register31 h'99 sci31 bit initial value read/write 7 brr317 1 r/w 6 brr316 1 r/w 5 brr315 1 r/w 4 brr314 1 r/w 3 brr313 1 r/w 0 brr310 1 r/w 2 brr312 1 r/w 1 brr311 1 r/w serial transmit/receive bit rate setting
431 scr31?erial control register 31 h'9a sci31 bit initial value read/write 7 tie31 0 r/w 6 rie31 0 r/w 5 te31 0 r/w 0 cke310 0 r/w 2 teie31 0 r/w 1 cke311 0 r/w 4 re31 0 r/w receive interrupt enable 0 receive data full interrupt request (rxi) and receive error interrupt request (eri) disabled 1 receive data full interrupt request (rxi) and receive error interrupt request (eri) enabled multiprocessor interrupt enable 0 multiprocessor interrupt request disabled (normal receive operation) [clearing conditions] when data is received in which the multiprocessor bit is set to 1 1 multiprocessor interrupt request enabled the receive interrupt request (rxi), receive error interrupt request (eri), and setting of the rdrf, fer, and oer flags in the serial status register (ssr), are disabled until data with the multiprocessor bit set to 1 is received. transmit enable 0 transmit operation disabled (txd pin is transmit data pin) 1 transmit operation enabled (txd pin is transmit data pin) receive enable 0 receive operation disabled (rxd pin is i/o port) 1 receive operation enabled (rxd pin is receive data pin) transmit end interrupt enable clock enable 0 bit 1 cke311 0 0 1 1 bit 0 cke310 0 1 0 1 communication mode asynchronous synchronous asynchronous synchronous asynchronous synchronous asynchronous synchronous internal clock internal clock internal clock reserved (do not specify this combination) external clock external clock reserved (do not specify this combination) reserved (do not specify this combination) i/o port serial clock output clock output clock input serial clock input clock source sck pin function description transmit end interrupt request (tei) disabled 1 transmit end interrupt request (tei) enabled transmit interrupt enable 0 transmit data empty interrupt request (txi) disabled 1 transmit data empty interrupt request (txi) enabled 3 mpie31 0 r/w 3
432 tdr31?ransmit data register 31 h'9b sci31 bit initial value read/write 7 tdr317 1 r/w 6 tdr316 1 r/w 5 tdr315 1 r/w 4 tdr314 1 r/w 3 tdr313 1 r/w 0 tdr310 1 r/w 2 tdr312 1 r/w 1 tdr311 1 r/w data for transfer to tsr
433 ssr31?erial status register31 h'9c sci3 bit initial value read/write note: * only a write of 0 for flag clearing is possible. 7 tdre31 1 r/(w) 6 rdrf31 0 r/(w) 5 oer31 0 r/(w) 0 mpbt31 0 r/w 2 tend31 1 r 1 mpbr31 0 r 4 fer31 0 r/(w) receive data register full 0 there is no receive data in rdr31 [clearing conditions] after reading rdrf31 = 1, cleared by writing 0 to rdrf31 when rdr31 data is read by an instruction 1 there is receive data in rdr31 [setting conditions] when reception ends normally and receive data is transferred from rsr31 to rdr31 transmit data register empty 0 transmit data written in tdr31 has not been transferred to tsr31 [clearing conditions] after reading tdre31 = 1, cleared by writing 0 to tdre31 when data is written to tdr31 by an instruction 1 transmit data has not been written to tdr31, or transmit data written in tdr31 has been transferred to tsr31 [setting conditions] when bit te in serial control register 31 (scr31) is cleared to 0 when data is transferred from tdr31 to tsr31 transmit end 0 transmission in progress [clearing conditions] 1 transmission ended [setting conditions] parity error 0 reception in progress or completed normally [clearing conditions] after reading per31 = 1, cleared by writing 0 to per31 1 a parity error has occurred during reception [setting conditions] framing error 0 reception in progress or completed normally [clearing conditions] after reading fer31 = 1, cleared by writing 0 to fer31 1 a framing error has occurred during reception [setting conditions] when the stop bit at the end of the receive data is checked for a value of 1 at completion of reception, and the stop bit is 0 overrun error 0 reception in progress or completed [clearing conditions] after reading oer31 = 1, cleared by writing 0 to oer31 1 an overrun error has occurred during reception [setting conditions] when the next serial reception is completed with rdrf31 set to 1 multiprocessor bit receive multiprocessor bit transfer 0 data in which the multiprocessor bit is 0 has been received 1 data in which the multiprocessor bit is 1 has been received 0 a 0 multiprocessor bit is transmitted 1 a 1 multiprocessor bit is transmitted 3 per31 0 r/(w) ***** after reading tdre31 = 1, cleared by writing 0 to tdre when data is written to tdr31 by an instruction when bit te in serial control register 31 (scr31) is cleared to 0 when bit tdre31 is set to 1 when the last bit of a transmit character is sent when the number of 1 bits in the receive data plus parity bit does not match the parity designated by the parity mode bit (pm31) in the serial mode register (smr31)
434 rdr31?eceive data register 31 h'f9d sci31 bit initial value read/write 7 rdr317 0 r 6 rdr316 0 r 5 rdr315 0 r 4 rdr314 0 r 3 rdr313 0 r 0 rdr310 0 r 2 rdr312 0 r 1 rdr311 0 r serial receive data
435 scr1?erial control register 1 h'a0 sci1 bit initial value read/write 7 snc1 0 r/w 6 snc0 0 r/w 5 mrkon 0 r/w 4 ltch 0 r/w 3 cks3 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w operating mode select clock source select 0 clock source is prescaler s, sck 1 is output 1 clock source is external clock, sck 1 is input latch tail select 0 hold tail is output 1 latch tail is output tail mark control 0 tail mark is not output (synchronous mode) 1 tail mark is output (ssb mode) 0 8-bit synchronous mode 16-bit synchronous mode 1 0 1 0 1 continuous clock output mode reserved clock select 2 to 0 bit 2 cks2 cks1 cks0 bit 1 bit 0 0 /1024 /256 1 1 0 /64 /32 1 /16 10 1 1 0 0 1 /8 00 00 0 1 0 /4 1 1 1 0 1 w /4 = 2.5 mhz 409.6 s 102.4 s 25.6 s 12.8 s 6.4 s 3.2 s 1.6 s 50 s or 104.2 s clock cycle serial clock cycle prescaler division ratio
436 scsr1?erial control status register 1 h'a1 sci1 bit initial value read/write 7 1 6 sol 0 r/w 5 orer 0 r/(w) 4 1 3 1 0 stf 0 r/w 2 1 1 mtrf 0 r extension data bit overrun error flag * start flag 0 transfer operation stopped invalid transfer operation in progress starts transfer operation 1 read write read write note: * only a write of 0 for flag clearing is possible. 0 clearing conditions: after reading orer = 1, cleared by writing 0 to orer 1 setting conditions: when an external clock is used and the clock is input after transfer is completed 0so 1 output level is low changes so 1 output to low level so 1 output level is high changes so 1 output to high level 1 read write read write tail mark transmission flag 0 idle state, or 8-bit/16-bit data transfer in progress 1 tail mark transmission in progress
437 sdru?erial data register u h'a2 sci1 bit initial value read/write 7 sdru7 undefined r/w 6 sdru6 undefined r/w 5 sdru5 undefined r/w 4 sdru4 undefined r/w 3 sdru3 undefined r/w 0 sdru0 undefined r/w 2 sdru2 undefined r/w 1 sdru1 undefined r/w used for transmit data setting and receive data storage 8-bit transfer mode: not used 16-bit transfer mode: upper 8 bits of data register sdrl?erial data register l h'a3 sci1 bit initial value read/write 7 sdrl7 undefined r/w 6 sdrl6 undefined r/w 5 sdrl5 undefined r/w 4 sdrl4 undefined r/w 3 sdrl3 undefined r/w 0 sdrl0 undefined r/w 2 sdrl2 undefined r/w 1 sdrl1 undefined r/w used for transmit data setting and receive data storage 8-bit transfer mode: data register 16-bit transfer mode: lower 8 bits of data register
438 smr32?erial mode register 32 h'a8 sci32 bit initial value read/write 7 com32 0 r/w 6 chr32 0 r/w 5 pe32 0 r/w 0 cks320 0 r/w 2 mp32 0 r/w 1 cks321 0 r/w 4 pm32 0 r/w clock select 0 0 01 1 1 1 clock w/2 clock/ w clock 0 /16 clock /64 clock multiprocessor mode 0 multiprocessor communication function disabled 1 multiprocessor communication function enabled stop bit length 0 1 stop bit 1 2 stop bits parity mode 0 even parity 1 odd parity parity enable 0 parity bit addition and checking disabled 1 parity bit addition and checking enabled character length 0 8-bit data/5-bit data 1 7-bit data/5-bit data communication mode 0 asynchronous mode 1 synchronous mode 3 stop32 0 r/w
439 brr32?it rate register 32 h'a9 sci32 bit initial value read/write 7 brr327 1 r/w 6 brr326 1 r/w 5 brr325 1 r/w 4 brr324 1 r/w 3 brr323 1 r/w 0 brr3120 1 r/w 2 brr322 1 r/w 1 brr321 1 r/w serial transmit/receive bit rate setting
440 scr32?erial control register 32 h'aa sci32 bit initial value read/write 7 tie32 0 r/w 6 rie32 0 r/w 5 te32 0 r/w 0 cke320 0 r/w 2 teie32 0 r/w 1 cke321 0 r/w 4 re32 0 r/w receive interrupt enable 0 receive data full interrupt request (rxi) and receive error interrupt request (eri) disabled 1 receive data full interrupt request (rxi) and receive error interrupt request (eri) enabled multiprocessor interrupt enable 0 multiprocessor interrupt request disabled (normal receive operation) [clearing conditions] when data is received in which the multiprocessor bit is set to 1 1 multiprocessor interrupt request enabled the receive interrupt request (rxi), receive error interrupt request (eri), and setting of the rdrf, fer, and oer flags in the serial status register (ssr), are disabled until data with the multiprocessor bit set to 1 is received. transmit enable 0 transmit operation disabled (txd pin is transmit data pin) 1 transmit operation enabled (txd pin is transmit data pin) receive enable 0 receive operation disabled (rxd pin is i/o port) 1 receive operation enabled (rxd pin is receive data pin) transmit end interrupt enable clock enable 0 bit 1 cke321 0 0 1 1 bit 0 cke320 0 1 0 1 communication mode asynchronous synchronous asynchronous synchronous asynchronous synchronous asynchronous synchronous internal clock internal clock internal clock reserved (do not specify this combination) external clock external clock reserved (do not specify this combination) reserved (do not specify this combination) i/o port serial clock output clock output clock input serial clock input clock source sck pin function description transmit end interrupt request (tei) disabled 1 transmit end interrupt request (tei) enabled transmit interrupt enable 0 transmit data empty interrupt request (txi) disabled 1 transmit data empty interrupt request (txi) enabled 3 mpie32 0 r/w 3
441 tdr32?ransmit data register 32 h'ab sci32 bit initial value read/write 7 tdr327 1 r/w 6 tdr326 1 r/w 5 tdr325 1 r/w 4 tdr324 1 r/w 3 tdr323 1 r/w 0 tdr320 1 r/w 2 tdr322 1 r/w 1 tdr321 1 r/w data for transfer to tsr
442 ssr32?erial status register 32 h'ac sci32 bit initial value read/write note: * only a write of 0 for flag clearing is possible. 7 tdre32 1 r/(w) 6 rdrf32 0 r/(w) 5 oer32 0 r/(w) 0 mpbt32 0 r/w 2 tend32 1 r 1 mpbr32 0 r 4 fer32 0 r/(w) receive data register full 0 there is no receive data in rdr32 [clearing conditions] after reading rdrf32 = 1, cleared by writing 0 to rdrf32 when rdr32 data is read by an instruction 1 there is receive data in rdr32 [setting conditions] when reception ends normally and receive data is transferred from rsr32 to rdr32 transmit data register empty 0 transmit data written in tdr32 has not been transferred to tsr32 [clearing conditions] after reading tdre32 = 1, cleared by writing 0 to tdre32 when data is written to tdr32 by an instruction 1 transmit data has not been written to tdr32, or transmit data written in tdr32 has been transferred to tsr32 [setting conditions] when bit te32 in serial control register 32 (scr32) is cleared to 0 when data is transferred from tdr32 to tsr32 transmit end 0 transmission in progress [clearing conditions] 1 transmission ended [setting conditions] parity error 0 reception in progress or completed normally [clearing conditions] after reading per32 = 1, cleared by writing 0 to per32 1 a parity error has occurred during reception [setting conditions] framing error 0 reception in progress or completed normally [clearing conditions] after reading fer32 = 1, cleared by writing 0 to fer32 1 a framing error has occurred during reception [setting conditions] when the stop bit at the end of the receive data is checked for a value of 1 at completion of reception, and the stop bit is 0 overrun error 0 reception in progress or completed [clearing conditions] after reading oer32 = 1, cleared by writing 0 to oer32 1 an overrun error has occurred during reception [setting conditions] when the next serial reception is completed with rdrf32 set to 1 multiprocessor bit receive multiprocessor bit transfer 0 data in which the multiprocessor bit is 0 has been received 1 data in which the multiprocessor bit is 1 has been received 0 a 0 multiprocessor bit is transmitted 1 a 1 multiprocessor bit is transmitted 3 per32 0 r/(w) ***** after reading tdre32 = 1, cleared by writing 0 to tdre32 when data is written to tdr32 by an instruction when bit te in serial control register 32 (scr32) is cleared to 0 when bit tdre32 is set to 1 when the last bit of a transmit character is sent when the number of 1 bits in the receive data plus parity bit does not match the parity designated by the parity mode bit (pm32) in the serial mode register (smr32)
443 rdr32?eceive data register 32 h'ad sci32 bit initial value read/write 7 rdr327 0 r 6 rdr326 0 r 5 rdr325 0 r 4 rdr324 0 r 3 rdr323 0 r 0 rdr320 0 r 2 rdr322 0 r 1 rdr321 0 r serial receive data tma?imer mode register a h'b0 timer a bit initial value read/write 7 tma7 0 r/w 6 tma6 0 r/w 5 tma5 0 r/w 0 tma0 0 r/w 2 tma2 0 r/w 1 tma1 0 r/w internal clock select tma3 tma2 0 pss pss pss pss 0 4 1 clock output select * 0 /32 /16 tma1 0 1 tma0 0 0 0 0 001 0 1 0 0 0 1 pss pss pss pss 10 1 0 0 10 0 10 1 0 11 1 1 psw psw psw psw 00 1 0 1 00 1 00 1 1 0 1 1 1 psw and tca are reset 10 1 0 1 10 1 1 0 1 1 1 1 1 prescaler and divider ratio or overflow period /8192 /4096 /2048 /512 /256 /128 /32 /8 w /32768 w /16384 w /8192 w /1024 interval timer time base (overflow period) function 0 0 00 001 /8 /4 1 01 1 1 00 101 1 10 1 note: values when bit cwos = 0 in cwosr. when bit cwos = 1, w is output regardless of the value of bits tma7 to tma5. * 11 /32 w /16 w /8 w /4 w 3 tma3 0 r/w
444 tca timer counter a h'b1 timer a bit initial value read/write 7 tca7 0 r 6 tca6 0 r 5 tca5 0 r 4 tca4 0 r 3 tca3 0 r 0 tca0 0 r 2 tca2 0 r 1 tca1 0 r count value
445 tcsrw timer control/status register w h'b2 watchdog timer bit initial value read/write 7 b6wi 1 r 6 tcwe 0 r/(w) 5 b4wi 1 r 4 tcsrwe 0 r/(w) 3 b2wi 1 r 0 wrst 0 r/(w) 2 wdon 0 r/(w) 1 b0wi 1 r ** * * watchdog timer reset 0 [clearing conditions] 1 [setting condition] when tcw overflows and a reset signal is generated reset by res pin when tcsrwe = 1, and 0 is written in both b0wi and wrst bit 0 write inhibit 0 bit 0 is write-enabled bit 0 is write-protected 1 watchdog timer on 0 watchdog timer operation is disabled watchdog timer operation is enabled 1 bit 2 write inhibit 0 bit 2 is write-enabled bit 2 is write-protected 1 timer control/status register w write enable 0 data cannot be written to bits 2 and 0 data can be written to bits 2 and 0 1 bit 4 write inhibit 0 bit 4 is write-enabled bit 4 is write-protected 1 timer counter w write enable 0 data cannot be written to tcw data can be written to tcw 1 bit 6 write inhibit 0 bit 6 is write-enabled bit 6 is write-protected 1 note: * write is permitted only under certain conditions.
446 tcw timer counter w h'b3 watchdog timer bit initial value read/write 7 tcw7 0 r/w 6 tcw6 0 r/w 5 tcw5 0 r/w 4 tcw4 0 r/w 3 tcw3 0 r/w 0 tcw0 0 r/w 2 tcw2 0 r/w 1 tcw1 0 r/w count value tmc timer mode register c h'b4 timer c bit initial value read/write 7 tmc7 0 r/w 6 tmc6 0 r/w 5 tmc5 0 r/w 3 1 0 tmc0 0 r/w 2 tmc2 0 r/w 1 tmc1 0 r/w 4 1 auto-reload function select clock select internal clock: internal clock: 0 1 internal clock: internal clock: 0 1 0 1 0 1 0 0 1 1 0 0 1 1 0 0 0 0 1 1 1 1 internal clock: internal clock: internal clock: external event (tmic): counting on rising or falling edge * don t care /8192 /2048 /512 /64 /16 /4 w/4 0 interval timer function selected 1 auto-reload function selected counter up/down control 0 tcc is an up-counter 1 tcc is a down-counter * hardware control of tcc up/down operation by ud pin input ud pin input high: down-counter ud pin input low: up-counter 0 0 1
447 tcc timer counter c h'b5 timer c bit initial value read/write 7 tcc7 0 r 6 tcc6 0 r 5 tcc5 0 r 4 tcc4 0 r 3 tcc3 0 r 0 tcc0 0 r 2 tcc2 0 r 1 tcc1 0 r count value tlc timer load register c h'b5 timer c bit initial value read/write 7 tlc7 0 r/w 6 tlc6 0 r/w 5 tlc5 0 r/w 4 tlc4 0 r/w 3 tlc3 0 r/w 0 tlc0 0 r/w 2 tlc2 0 r/w 1 tlc1 0 r/w reload value note: tlc is allocated to the same address as tcc. in a write, the value is written to tlc.
448 tcrf timer control register f h'b6 timer f bit initial value read/write 7 tolh 0 w 6 cksh2 0 w 5 cksh1 0 w 0 cksl0 0 w 2 cksl2 0 w 1 cksl1 0 w 4 cksh0 0 w clock select l 0 counting on external event (tmif) rising/falling edge not available internal clock /32 internal clock /16 internal clock /4 internal clock w/4 1 1 1 1 0 0 0 1 1 * 0 1 0 1 011 010 toggle output level l 0 low level 1 high level toggle output level h 0 low level 1 high level 3 toll 0 w clock select h 0 overflow signal not available internal clock /32 internal clock /16 internal clock /4 internal clock w/4 16-bit mode, counting on tcfl * don t care * don t care 1 1 1 1 0 0 0 1 1 * 0 010 1 0 1 011
449 tcsrf timer control/status register f h'b7 timer f bit initial value read/write note: * bits 7, 6, 3, and 2 can only be written with 0, for flag clearing. 7 ovfh 0 r/(w) * 6 cmfh 0 r/(w) * 5 ovieh 0 r/w 0 cclrl 0 r/w 2 cmfl 0 r/(w) * 1 oviel 0 r/w 4 cclrh 0 r/w compare match flag h 0 clearing conditions: after reading cmfh = 1, cleared by writing 0 to cmfh 1 setting conditions: set when the tcfh value matches the ocrfh value timer overflow flag h 0 clearing conditions: after reading ovfh = 1, cleared by writing 0 to ovfh 1 setting conditions: set when tcfh overflows from h'ff to h'00 compare match flag l 0 clearing conditions: after reading cmfl = 1, cleared by writing 0 to cmfl 1 setting conditions: set when the tcfl value matches the ocrfl value timer overflow flag l 0 clearing conditions: after reading ovfl = 1, cleared by writing 0 to ovfl 1 setting conditions: set when tcfl overflows from h'ff to h'00 counter clear h 0 16-bit mode: tcf clearing by compare match is disabled 8-bit mode: tcfh clearing by compare match is disabled 1 16-bit mode: tcf clearing by compare match is enabled 8-bit mode: tcfh clearing by compare match is enabled timer overflow interrupt enable h 0 tcfh overflow interrupt request is disabled 1 tcfh overflow interrupt request is enabled timer overflow interrupt enable l counter clear l 0 tcfl overflow interrupt request is disabled 1 tcfl overflow interrupt request is enabled 0 tcfl clearing by compare match is disabled 1 tcfl clearing by compare match is enabled 3 ovfl 0 r/(w) *
450 tcfh 8-bit timer counter fh h'b8 timer f bit initial value read/write 7 tcfh7 0 r/w 6 tcfh6 0 r/w 5 tcfh5 0 r/w 4 tcfh4 0 r/w 3 tcfh3 0 r/w 0 tcfh0 0 r/w 2 tcfh2 0 r/w 1 tcfh1 0 r/w count value note: tcfh and tcfl can also be used as the upper and lower halves, respectively, of a 16-bit timer counter (tcf). tcfl 8-bit timer counter fl h'b9 timer f bit initial value read/write 7 tcfl7 0 r/w 6 tcfl6 0 r/w 5 tcfl5 0 r/w 4 tcfl4 0 r/w 3 tcfl3 0 r/w 0 tcfl0 0 r/w 2 tcfl2 0 r/w 1 tcfl1 0 r/w count value note: tcfh and tcfl can also be used as the upper and lower halves, respectively, of a 16-bit timer counter (tcf). ocrfh output compare register fh h'ba timer f bit initial value read/write 7 ocrfh7 1 r/w 6 ocrfh6 1 r/w 5 ocrfh5 1 r/w 4 ocrfh4 1 r/w 3 ocrfh3 1 r/w 0 ocrfh0 1 r/w 2 ocrfh2 1 r/w 1 ocrfh1 1 r/w note: ocrfh and ocrfl can also be used as the upper and lower halves, respectively, of a 16-bit output compare register (ocrf).
451 ocrfl output compare register fl h'bb timer f bit initial value read/write 7 ocrfl7 1 r/w 6 ocrfl6 1 r/w 5 ocrfl5 1 r/w 4 ocrfl4 1 r/w 3 ocrfl3 1 r/w 0 ocrfl0 1 r/w 2 ocrfl2 1 r/w 1 ocrfl1 1 r/w note: ocrfh and ocrfl can also be used as the upper and lower halves, respectively, of a 16-bit output compare register (ocrf).
452 tmg timer mode register g h'bc timer g bit initial value read/write 7 ovfh 0 r/(w)* 6 ovfl 0 r/(w)* 5 ovie 0 w 3 cclr1 0 w 0 cks0 0 w 2 cclr0 0 w 1 cks1 0 w 4 iiegs 0 w timer overflow flag h counter clear tcg clearing is disabled tcg cleared by falling edge of input capture input signal tcg cleared by rising edge of input capture input signal tcg cleared by both edges of input capture input signal 0 1 0 1 0 0 1 1 timer overflow interrupt enable tcg overflow interrupt request is disabled tcg overflow interrupt request is enabled 0 1 0 clearing conditions: after reading ovfh = 1, cleared by writing 0 to ovfh 1 setting conditions: set when tcg overflows from h'ff to h'00 note: * bits 7 and 6 can only be written with 0, for flag clearing. timer overflow flag l 0 clearing conditions: after reading ovfl = 1, cleared by writing 0 to ovfl 1 setting conditions: set when tcg overflows from h'ff to h'00 input capture interrupt edge select 0 interrupt generated on rising edge of input capture input signal 1 interrupt generated on falling edge of input capture input signal clock select 0 internal clock: counting on /64 0 internal clock: counting on /32 0 1 1 internal clock: counting on /2 1 internal clock: counting on w/4 0 1
453 icrgf input capture register gf h'bd timer g bit initial value read/write 7 icrgf7 0 r 6 icrgf6 0 r 5 icrgf5 0 r 4 icrgf4 0 r 3 icrgf3 0 r 0 icrgf0 0 r 2 icrgf2 0 r 1 icrgf1 0 r store tcg value at falling edge of input capture signal icrgr input capture register gr h'be timer g bit initial value read/write 7 icrgr7 0 r 6 icrgr6 0 r 5 icrgr5 0 r 4 icrgr4 0 r 3 icrgr3 0 r 0 icrgr0 0 r 2 icrgr2 0 r 1 icrgr1 0 r store tcg value at rising edge of input capture signal
454 amr a/d mode register h'c6 a/d converter bit initial value read/write 7 cks 0 r/w 6 trge 0 r/w 4 1 3 ch3 0 r/w 0 ch0 0 r/w 2 ch2 0 r/w 1 ch1 0 r/w channel select no channel selected bit 3 0 0 0 0 0 bit 2 analog input channel * don t care ch3 ch2 0 ch1 ch0 bit 1 bit 0 0an 1 1 0 1 1 00 1 0 1 0 1 1 1 0 0 external trigger select 0 disables start of a/d conversion by external trigger 1 enables start of a/d conversion by rising or falling edge of external trigger at pin adtrg 5 1 4 an 5 an 6 an 7 ** 1 1 1 1 0 0 0 1 1 1 0 1 * reserved 1 * an 0 an 1 an 2 an 3 clock select 62/ bit 7 0 conversion period cks 31/ 1 62 s = 1 mhz 31 s 12.4 s = 5 mhz * conversion time note: * operation is not guaranteed with a conversion time of less than 12.4 s select a setting that gives a conversion time of at least 12.4 s.
455 adrrh a/d result register h h'c4 a/d converter adrrl a/d result register l h'c5 bit initial value read/write adrrh 7 adr9 undefined r 6 adr8 undefined r 5 adr7 undefined r 3 adr5 undefined r 0 adr2 undefined r 2 adr4 undefined r 1 adr3 undefined r 4 adr6 undefined r a/d conversion result bit initial value read/write adrrl 7 adr1 undefined r 6 adr0 undefined r 5 3 0 2 1 4 a/d conversion result adsr a/d start register h'c7 a/d converter bit initial value read/write 7 adsf 0 r/w 6 1 5 1 4 1 3 1 0 1 2 1 1 1 a/d status flag 0 1 read write read write indicates completion of a/d conversion stops a/d conversion indicates a/d conversion in progress starts a/d conversion
456 pmr1 port mode register 1 h'c8 i/o port bit initial value read/write 7 irq3 0 r/w 6 irq2 0 r/w 5 irq1 0 r/w 3 tmig 0 r/w 0 tmow 0 r/w 2 tmofh 0 r/w 1 tmofl 0 r/w 4 irq4 0 r/w p1 0 /tmow pin function switch 0 functions as p1 0 i/o pin 1 functions as tmow output pin p1 2 /tmofh pin function switch 0 functions as p1 2 i/o pin 1 functions as tmofh output pin p1 3 /tmig pin function switch 0 functions as p1 3 i/o pin 1 functions as tmig input pin p1 4 /irq 4 /adtrg pin function switch 0 functions as p1 4 i/o pin 1 functions as irq 4 /adtrg input pin p1 5 /irq 1 /tmic pin function switch 0 functions as p1 5 i/o pin 1 functions as irq 1 /tmic input pin p1 1 /tmofl pin function switch 0 functions as p1 1 i/o pin 1 functions as tmofl output pin p1 6 /irq 2 pin function switch 0 functions as p1 6 i/o pin 1 functions as irq 2 input pin p1 7 /irq 3 /tmif pin function switch 0 functions as p1 7 i/o pin 1 functions as irq 3 /tmif input pin
457 pmr2 port mode register 2 h'c9 i/o port bit initial value read/write 7 1 6 1 4 1 3 1 0 sck1 0 r/w 2 so1 0 r/w 1 si1 0 r/w 5 pof1 0 r/w p2 0 /sck 1 function switch 0 functions as p2 0 i/o functions as sck 1 i/o 1 p2 2 /so 1 function switch 0 functions as p2 2 i/o functions as so 1 output 1 p2 1 /si 1 function switch 0 functions as p2 1 i/o functions as si 1 input 1 p2 2 /so 1 function pmos control 0 cmos setting nmos open-drain setting 1
458 pmr3 port mode register 3 h'ca i/o port bit initial value read/write 7 0 6 0 5 wdcks 0 r/w 3 irq0 0 r/w 0 0 2 reso 0 r/w 1 ud 0 r/w 4 ncs 0 r/w p3 2 /reso pin function switch 0 functions as p3 2 i/o pin 1 functions as reso i/o pin p4 3 /irq0 pin function switch 0 functions as p4 3 i/o pin 1 functions as irq 0 input pin watchdog timer switch 0 8192 1 p3 1 /ud pin function switch 0 functions as p3 1 i/o pin 1 functions as ud input pin tmig noise canceler select 0 noise cancellation function not used 1 noise cancellation function used w/4 pmr4 port mode register 4 h'cb i/o port bit initial value read/write 7 0 6 0 5 0 4 nmod4 0 r/w 3 nmod3 0 r/w 0 nmod0 0 r/w 2 nmod2 0 r/w 1 nmod1 0 r/w 0 cmos setting (n = 4 to 0) 1 nmos open-drain setting note: when the pcr2 specification is 1 (output port specification)
459 pmr5 port mode register 5 h'cc i/o port bit initial value read/write 7 wkp 7 0 r/w 6 wkp 6 0 r/w 5 wkp 5 0 r/w 3 wkp 3 0 r/w 0 wkp 0 0 r/w 2 wkp 2 0 r/w 1 wkp 1 0 r/w 4 wkp 4 0 r/w 0 functions as p5 n i/o pin p5 n /wkp n pin function switch 1 functions as wkp n input pin (n = 7 to 0) pdr1 port data register 1 h'd4 i/o ports bit initial value read/write 7 p1 0 r/w 6 p1 0 r/w 5 p1 0 r/w 4 p1 0 r/w 3 p1 0 r/w 0 p1 0 r/w 2 p1 0 r/w 1 p1 0 r/w 7 6543210 data for port 1 pins pdr2 port data register 2 h'd5 i/o ports bit initial value read/write 7 0 6 0 5 0 4 p2 4 0 r/w 3 p2 3 0 r/w 0 p2 0 0 r/w 2 p2 2 0 r/w 1 p2 1 0 r/w data for port 2 pins
460 pdr3 port data register 3 h'd6 i/o ports bit initial value read/write 7 p3 0 r/w 6 p3 0 r/w 5 p3 0 r/w 4 p3 0 r/w 3 p3 0 r/w 0 p3 0 r/w 2 p3 0 r/w 1 p3 0 r/w 0 2 3 4 5 6 7 1 data for port 3 pins pdr4 port data register 4 h'd7 i/o ports bit initial value read/write 7 1 6 1 5 1 4 1 3 p4 1 r 0 p4 0 r/w 2 p4 0 r/w 1 p4 0 r/w 30 21 data for port pins p4 2 to p4 0 reads p4 3 state pdr5 port data register 5 h'd8 i/o ports bit initial value read/write 7 p5 0 r/w 6 p5 0 r/w 5 p5 0 r/w 4 p5 0 r/w 3 p5 0 r/w 0 p5 0 r/w 2 p5 0 r/w 1 p5 0 r/w 30 21 4 5 6 7 data for port 5 pins
461 pdr6 port data register 6 h'd9 i/o ports bit initial value read/write 7 p6 0 r/w 6 p6 0 r/w 5 p6 0 r/w 4 p6 0 r/w 3 p6 0 r/w 0 p6 0 r/w 2 p6 0 r/w 1 p6 0 r/w 30 21 4 5 6 7 data for port 6 pins pdr7 port data register 7 h'da i/o ports bit initial value read/write 7 p7 0 r/w 6 p7 0 r/w 5 p7 0 r/w 4 p7 0 r/w 3 p7 0 r/w 0 p7 0 r/w 2 p7 0 r/w 1 p7 0 r/w 3210 4 5 6 7 data for port 7 pins pdr8 port data register 8 h'db i/o ports bit initial value read/write 7 p8 0 r/w 6 p8 0 r/w 5 p8 0 r/w 4 p8 0 r/w 3 p8 0 r/w 0 p8 0 r/w 2 p8 0 r/w 1 p8 0 r/w 30 21 4 5 6 7 data for port 8 pins
462 pdr9 port data register 9 h'dc i/o ports bit initial value read/write 7 0 6 0 5 0 4 0 3 p9 3 0 r/w 0 p9 0 0 r/w 2 p9 2 0 r/w 1 p9 1 0 r/w data for port 9 pins pdra port data register a h'dd i/o ports bit initial value read/write 7 1 6 1 5 1 4 1 3 pa 0 r/w 0 pa 0 r/w 2 pa 0 r/w 1 pa 0 r/w 30 21 data for port a pins pdrb port data register b h'de i/o ports bit read/write 7 pb r 6 pb r 5 pb r 4 pb r 3 pb r 0 pb r 2 pb r 1 pb r 30 21 4 5 6 7 read port b pin states
463 pucr1 port pull-up control register 1 h'e0 i/o ports bit initial value read/write 7 pucr1 0 r/w 6 pucr1 0 r/w 5 pucr1 0 r/w 4 pucr1 0 r/w 3 pucr1 0 r/w 0 pucr1 0 r/w 2 pucr1 0 r/w 1 pucr1 0 r/w 0 43 21 5 6 7 note: when the pcr1 specification is 0 (input port specification) port 1 input pull-up mos control 0 input pull-up mos is off 1 input pull-up mos is on pucr3 port pull-up control register 3 h'e1 i/o ports bit initial value read/write 7 pucr3 0 r/w 6 pucr3 0 r/w 5 pucr3 0 r/w 4 pucr3 0 r/w 3 pucr3 0 r/w 0 pucr3 0 r/w 2 pucr3 0 r/w 1 pucr3 0 r/w 0 2 3 4 5 6 7 1 note: when the pcr3 specification is 0 (input port specification) port 3 input pull-up mos control 0 input pull-up mos is off 1 input pull-up mos is on
464 pucr5 port pull-up control register 5 h'e2 i/o ports bit initial value read/write 7 pucr5 0 r/w 6 pucr5 0 r/w 5 pucr5 0 r/w 4 pucr5 0 r/w 3 pucr5 0 r/w 0 pucr5 0 r/w 2 pucr5 0 r/w 1 pucr5 0 r/w 30 21 4 5 6 7 note: when the pcr5 specification is 0 (input port specification) port 5 input pull-up mos control 0 input pull-up mos is off 1 input pull-up mos is on pucr6 port pull-up control register 6 h'e3 i/o ports bit initial value read/write 7 pucr6 0 r/w 6 pucr6 0 r/w 5 pucr6 0 r/w 4 pucr6 0 r/w 3 pucr6 0 r/w 0 pucr6 0 r/w 2 pucr6 0 r/w 1 pucr6 0 r/w 30 21 4 5 6 7 note: when the pcr6 specifications 0 (input port specification) port 6 input pull-up mos control 0 input pull-up mos is off 1 input pull-up mos is on pcr1 port control register 1 h'e4 i/o ports bit initial value read/write 7 pcr1 0 w 6 pcr1 0 w 5 pcr1 0 w 4 pcr1 0 w 3 pcr1 0 w 0 pcr1 0 w 2 pcr1 0 w 1 pcr1 0 w port 1 input/output select 0 input pin 1 output pin 7 6543210
465 pcr2 port control register 2 h'e5 i/o ports bit initial value read/write 7 1 6 1 5 1 4 pcr2 4 0 w 3 pcr2 3 0 w 0 pcr2 0 0 w 2 pcr2 2 0 w 1 pcr2 1 0 w port 2 input/output select 0 input pin 1 output pin pcr3 port control register 3 h'e6 i/o ports bit initial value read/write 7 pcr3 0 w 6 pcr3 0 w 5 pcr3 0 w 4 pcr3 0 w 3 pcr3 0 w 0 pcr3 0 w 2 pcr3 0 w 1 pcr3 0 w port 3 input/output select 0 input pin 1 output pin 0 2 3 4 5 6 7 1 pcr4 port control register 4 h'e7 i/o ports bit initial value read/write 7 1 6 1 5 1 4 1 3 1 0 pcr4 0 w 2 pcr4 0 w 1 pcr4 0 w port 4 input/output select 0 input pin 1 output pin 0 21
466 pcr5 port control register 5 h'e8 i/o ports bit initial value read/write 7 pcr5 0 w 6 pcr5 0 w 5 pcr5 0 w 4 pcr5 0 w 3 pcr5 0 w 0 pcr5 0 w 2 pcr5 0 w 1 pcr5 0 w port 5 input/output select 0 input pin 1 output pin 76543 0 21 pcr6 port control register 6 h'e9 i/o ports bit initial value read/write 7 pcr6 0 w 6 pcr6 0 w 5 pcr6 0 w 4 pcr6 0 w 3 pcr6 0 w 0 pcr6 0 w 2 pcr6 0 w 1 pcr6 0 w port 6 input/output select 0 input pin 1 output pin 76543 0 21 pcr7 port control register 7 h'ea i/o ports bit initial value read/write 7 pcr7 0 w 6 pcr7 0 w 5 pcr7 0 w 4 pcr7 0 w 3 pcr7 0 w 0 pcr7 0 w 2 pcr7 0 w 1 pcr7 0 w port 7 input/output select 0 input pin 1 output pin 7 65 432 10
467 pcr8 port control register 8 h'eb i/o ports bit initial value read/write 7 pcr8 0 w 6 pcr8 0 w 5 pcr8 0 w 4 pcr8 0 w 3 pcr8 0 w 0 pcr8 0 w 2 pcr8 0 w 1 pcr8 0 w port 8 input/output select 0 input pin 1 output pin 76543 0 21 pcr9 port control register 9 h'ec i/o ports bit initial value read/write 7 1 6 1 5 1 4 1 3 pcr9 3 0 w 0 pcr9 0 0 w 2 pcr9 2 0 w 1 pcr9 1 0 w port 9 input/output select 0 input pin 1 output pin pcra port control register a h'ed i/o ports bit initial value read/write 7 0 6 0 5 0 4 0 3 pcra 0 w 0 pcra 0 w 2 pcra 0 w 1 pcra 0 w 0 1 2 3 port a input/output select 0 input pin 1 output pin
468 syscr1 system control register 1 h'f0 system control bit initial value read/write 7 ssby 0 r/w 6 sts2 0 r/w 5 sts1 0 r/w 3 lson 0 r/w 0 ma0 1 r/w 2 1 1 ma1 1 r/w 4 sts0 0 r/w software standby 0 when a sleep instruction is executed in active mode, a transition is made to sleep mode 1 standby timer select 2 to 0 0 wait time = 8,192 states wait time = 16,384 states 0 0 1 wait time = 1,024 states wait time = 2,048 states 10 1 active (medium-speed) mode clock select /16 /32 0 1 0 0 1 1 /64 /128 1 1 00 10 1 wait time = 4,096 states wait time = 2 states wait time = 8 states wait time = 16 states low speed on flag 0 the cpu operates on the system clock ( ) 1 the cpu operates on the subclock ( ) sub when a sleep instruction is executed in subactive mode, a transition is made to subsleep mode when a sleep instruction is executed in active mode, a transition is made to standby mode or watch mode when a sleep instruction is executed in subactive mode, a transition is made to watch mode osc osc osc osc
469 syscr2 system control register 2 h'f1 system control bit initial value read/write 7 1 6 1 5 1 3 dton 0 r/w 0 sa0 0 r/w 2 mson 0 r/w 1 sa1 0 r/w 4 nesel 1 r/w subactive mode clock select 0 /8 /4 0 1 1 /2 * w w w direct transfer on flag 0 when a sleep instruction is executed in active mode, a transition is made to standby mode, watch mode, or sleep mode 1 when a sleep instruction is executed in subactive mode, a transition is made to watch mode or subsleep mode when a sleep instruction is executed in active (high-speed) mode, a direct transition is made to active (medium-speed) mode if ssby = 0, mson = 1, and lson = 0, or to subactive mode if ssby = 1, tma3 = 1, and lson = 1 when a sleep instruction is executed in active (medium-speed) mode, a direct transition is made to active (high-speed) mode if ssby = 0, mson = 0, and lson = 0, or to subactive mode if ssby = 1, tma3 = 1, and lson = 1 when a sleep instruction is executed in subactive mode, a direct transition is made to active (high-speed) mode if ssby = 1, tma3 = 1, lson = 0, and mson = 0, or to active (medium-speed) mode if ssby = 1, tma3 = 1, lson = 0, and mson = 1 medium speed on flag 0 operates in active (high-speed) mode 1 operates in active (medium-speed) mode noise elimination sampling frequency select 0 sampling rate is /16 1 sampling rate is /4 osc osc * : don t care
470 iegr irq edge select register h'f2 system control bit initial value read/write 7 0 6 1 4 ieg4 0 r/w 3 ieg3 0 r/w 0 ieg0 0 r/w 2 ieg2 0 r/w 1 ieg1 0 r/w 5 1 irq 0 edge select 0 falling edge of irq 0 signal input is detected rising edge of irq 0 signal input is detected 1 irq 1 edge select 0 falling edge of irq 1 , tmic pin input is detected rising edge of irq 1 , tmic pin input is detected 1 irq 2 edge select 0 falling edge of irq 2 pin input is detected rising edge of irq 2 pin input is detected 1 irq 3 edge select 0 falling edge of irq 3 , tmif pin input is detected rising edge of irq 3 , tmif pin input is detected 1 irq 4 edge select 0 falling edge of irq 4 pin and adtrg pin is detected rising edge of irq 4 pin and adtrg pin is detected 1
471 ienr1 interrupt enable register 1 h'f3 system control bit initial value read/write 7 ienta 0 r/w 6 iens1 0 r/w 4 ien4 0 r/w 3 ien3 0 r/w 0 ien0 0 r/w 2 ien2 0 r/w 1 ien1 0 r/w 5 ienwp 0 r/w irq 4 to irq 0 interrupt enable 0 disables irq 4 to irq 0 interrupt requests enables irq 4 to irq 0 interrupt requests 1 wakeup interrupt enable 0 disables wkp 7 to wkp 0 interrupt requests enables wkp 7 to wkp 0 interrupt requests 1 timer a interrupt enable 0 disables timer a interrupt requests enables timer a interrupt requests 1 sci1 interrupt enable 0 disables sci1 interrupt requests enables sci1 interrupt requests 1 note: irq 0 is an internal signal that performs interfacing to the flex decoder incorporated in the chip. note: sci1 is an internal function that performs interfacing to the flex decoder incorporated in the chip.
472 ienr2 interrupt enable register 2 h'f4 system control bit initial value read/write 7 iendt 0 r/w 6 ienad 0 r/w 5 0 r/w 3 ientfh 0 r/w 0 0 2 ientfl 0 r/w 1 ientc 0 r/w 4 ientg 0 r/w timer fl interrupt enable 0 disables timer fl interrupt requests 1 enables timer fl interrupt requests timer fh interrupt enable 0 disables timer fh interrupt requests 1 enables timer fh interrupt requests timer g interrupt enable 0 disables timer g interrupt requests 1 enables timer g interrupt requests a/d converter interrupt enable 0 disables a/d converter interrupt requests 1 enables a/d converter interrupt requests timer c interrupt enable 0 disables timer c interrupt requests 1 enables timer c interrupt requests direct transition interrupt enable 0 disables direct transition interrupt requests 1 enables direct transition interrupt requests
473 irr1 interrupt request register 1 h'f6 system control bit initial value read/write 7 irrta 0 r/(w) * 6 irrs1 0 r/(w) * 5 1 3 irri3 0 r/(w) * 0 irri0 0 r/(w) * 2 irri2 0 r/(w) * 1 irri1 0 r/(w) * 4 irri4 0 r/(w) * irq4 to irq0 interrupt request flags 0 clearing conditions: when irrin = 1, it is cleared by writing 0 (n = 4 to 0) note: * bits 7, 6, and 4 to 0 can only be written with 0, for flag clearing. 1 setting conditions: when pin irqn is designated for interrupt input and the designated signal edge is input timer a interrupt request flag 0 clearing conditions: when irrta = 1, it is cleared by writing 0 1 setting conditions: when the timer a counter value overflows (rom h'ff to h'00) sci1 interrupt request flag 0 clearing conditions: when irrs1 = 1, it is cleared by writing 0 1 setting conditions: when sci1 completes transfer note: irq 0 is an internal signal that performs interfacing to the flex decoder incorporated in the chip. note: sci1 is an internal function that performs interfacing to the flex decoder incorporated in the chip.
474 irr2 interrupt request register 2 h'f7 system control bit initial value read/write 7 irrdt 0 r/(w) * 6 irrad 0 r/(w) * 5 0 r/w 3 irrtfh 0 r/(w) * 0 0 2 irrtfl 0 r/(w) * 1 irrtc 0 r/(w) * 4 irrtg 0 r/(w) * timer g interrupt request flag timer c interrupt request flag 0 clearing conditions: when irrtg = 1, it is cleared by writing 0 1 setting conditions: when the tmig pin is designated for tmig input and the designated signal edge is input note: * bits 7, 6 and 4 to 1 can only be written with 0, for flag clearing. a/d converter interrupt request flag 0 clearing conditions: when irrad = 1, it is cleared by writing 0 1 setting conditions: when the a/d converter completes conversion and adsf is reset direct transition interrupt request flag 0 clearing conditions: when irrdt = 1, it is cleared by writing 0 1 setting conditions: when a sleep instruction is executed while dton is set to 1, and a direct transition is made timer fh interrupt request flag 0 clearing conditions: when irrtfh = 1, it is cleared by writing 0 1 setting conditions: when counter fh and output compare register fh match in 8-bit timer mode, or when 16-bit counters fl and fh and output compare registers fl and fh match in 16-bit timer mode timer fl interrupt request flag 0 clearing conditions: when irrtfl = 1, it is cleared by writing 0 1 setting conditions: when counter fl and output compare register fl match in 8-bit timer mode 0 clearing conditions: when irrtc = 1, it is cleared by writing 0 1 setting conditions: when the timer c counter value overflows (from h'ff to h'00) or underflows (from h'00 to h'ff)
475 iwpr wakeup interrupt request register h'f9 system control bit initial value read/write 7 iwpf7 0 r/(w) * 6 iwpf6 0 r/(w) * 5 iwpf5 0 r/(w) * 3 iwpf3 0 r/(w) * 0 iwpf0 0 r/(w) * 2 iwpf2 0 r/(w) * 1 iwpf1 0 r/(w) * 4 iwpf4 0 r/(w) * 0 clearing conditions: when iwpfn = 1, it is cleared by writing 0 (n = 7 to 0) note: * all bits can only be written with 0, for flag clearing. wakeup interrupt request register 1 setting conditions: when pin wkpn is designated for wakeup input and a rising or falling edge is input at that pin
476 ckstpr1 clock stop register 1 h'fa system control bit initial value read/write 7 s1ckstp 1 r/w 6 s31ckstp 1 r/w 5 s32ckstp 1 r/w 3 tgckstp 1 r/w 0 tackstp 1 r/w 2 tfckstp 1 r/w 1 tcckstp 1 r/w 4 adckstp 1 r/w timer a module standby mode control timer f module standby mode control 0 timer f is set to module standby mode timer f module standby mode is cleared 1 timer g interrupt enable 0 timer g is set to module standby mode timer g module standby mode is cleared 1 a/d converter module standby mode control 0 a/d converter is set to module standby mode a/d converter module standby mode is cleared 1 timer c module standby mode control 0 timer c is set to module standby mode timer c module standby mode is cleared 1 0 timer a is set to module standby mode timer a module standby mode is cleared 1 sci32 module standby mode control 0 sci32 is set to module standby mode sci32 module standby mode is cleared 1 sci31 module standby mode control 0 sci31 is set to module standby mode sci31 module standby mode is cleared 1 sci1 module standby mode control 0 sci1 is set to module standby mode sci1 module standby mode is cleared 1
477 ckstpr2 clock stop register 2 h'fb system control bit initial value read/write 7 1 6 1 5 1 3 1 0 1 2 wdckstp 1 r/w 1 1 4 1 wdt module standby mode control 0 wdt is set to module standby mode wdt module standby mode is cleared 1
478 appendix c i/o port block diagrams c.1 block diagrams of port 1 v cc v cc v ss pucr1 n pmr1 n pdr1 n pcr1 n irq n? sby (low level during reset and in standby mode) internal data bus pdr1: pcr1: pmr1: pucr1: n = 7 to 4 port data register 1 port control register 1 port mode register 1 port pull-up control register 1 p1 n figure c-1 (a) port 1 block diagram (pins p1 7 to p1 4 )
479 v cc v cc sby v ss pucr1 3 pmr1 3 pdr1 3 pcr1 3 pdr1 pcr1 pmr1 pucr1 : port data register 1 : port control register 1 : port mode register 1 : port pull-up control register 1 internal data bus p1 3 tmig timer g module figure c-1 (b) port 1 block diagram (pin p1 3 )
480 v cc v cc v ss pucr1 n pmr1 n pdr1 n pcr1 n sby figure c-1 (c) port 1 block diagram (pins p1 2 and p1 1 )
481 v cc v cc v ss pucr1 0 pmr1 0 pdr1 0 pcr1 0 cwos sby w timer a module p1 0 figure c-1 (d) port 1 block diagram (pin p1 0 )
482 c.2 block diagrams of port 2 [chip internal i/o port] reset flex tm decoder pdr2 4 pcr2 4 pdr2: port data register 2 pcr2: port control register 2 internal data bus res (low in reset) figure c-2 (a) port 2 block diagram (pin p2 4 ) ss pdr2 3 pcr2 3 pdr2: port data register 2 pcr2: port control register 2 internal data bus res flex tm decoder figure c-2 (b) port 2 block diagram (pin p2 3 )
483 pdr2 2 pcr2 2 pdr2: port data register 2 pcr2: port control register 2 pmr2: port mode register 2 pmr2 2 internal data bus mosi res so 1 sci1 module flex tm decoder figure c-2 (c) port 2 block diagram (pin p2 2 )
484 pdr2 1 pcr2 1 pdr2: port data register 2 pcr2: port control register 2 pmr2: port mode register 2 pmr2 1 internal data bus miso res si 1 sci1 module flex tm decoder figure c-2 (d) port 2 block diagram (pin p2 1 )
485 pdr2 0 pcr2 0 pdr2: port data register 2 pcr2: port control register 2 pmr2: port mode register 2 pmr2 0 internal data bus sck res sck 0 sck 1 exck sci1 module flex tm decoder figure c-2 (e) port 2 block diagram (pin p2 0 )
486 c.3 block diagrams of port 3 p3 n v cc v cc pucr3 n pdr3 n pcr3 n internal data bus sby figure c-3 (a) port 3 block diagram (pins p3 7 and p3 6 )
487 p3 5 sci31 module pdr3 5 pucr3 5 scinv1 pcr3 5 sby figure c.3 (b) port 3 block diagram (pin p3 5 )
488 p3 4 v cc v cc sci31 module pdr3 4 pcr3 4 scinv0 sby figure c.3 (c) port 3 block diagram (pin p3 4 )
489 p3 3 v cc sci31 module pdr3 3 pcr3 3 sby figure c.3 (d) port 3 block diagram (pin p3 3 )
490 p3 2 v cc v cc pucr3 2 internal data bus pmr3 2 pdr3 2 pcr3 2 sby v ss pdr3: port data register 3 pcr3: port control register 3 pmr3: port mode register 3 pucr3: port pull-up control register 3 reso figure c.3 (e) port 3 block diagram (pin p3 2 )
491 v cc v cc v ss pucr3 1 pdr3 1 pcr3 1 ud sby figure c-3 (f) port 3 block diagram (pin p3 1 )
492 p3 0 v cc v cc pucr3 0 pdr3 0 pcr3 0 sby figure c-3 (g) port 3 block diagram (pin p3 0 )
493 c.4 block diagrams of port 4 pmr4: port mode register 4 pmr4 3 internal data bus ready flex tm decoder res irq 0 figure c.4 (a) port 4 block diagram (pin p4 3 ) [chip internal input port]
494 p4 2 sci32 module internal data bus pdr4 2 scinv3 pcr4 2 sby figure c.4 (b) port 4 block diagram (pin p4 2 )
495 p4 1 v cc sci32 module pdr4 1 pcr4 1 sby figure c.4 (c) port 4 block diagram (pin p4 1 )
496 p4 0 v cc sci32 module pdr4 0 pcr4 0 sby figure c.4 (d) port 4 block diagram (pin p4 0 )
497 c.5 block diagram of port 5 p5 n v cc v cc pucr5 n internal data bus pmr5 n pdr5 n pcr5 n sby v ss wkp n pdr5: port data register 5 pcr5: port control register 5 pmr5: port mode register 5 pucr5: port pull-up control register 5 n = 7 to 0 figure c.5 port 5 block diagram
498 c.6 block diagram of port 6 p6 n v cc v cc pucr6 n pdr6 n internal data bus pcr6 n sby figure c.6 port 6 block diagram
499 c.7 block diagram of port 7 p7 n v cc pdr7 n internal data bus pcr7 n sby v ss pdr7: port data register 7 pcr7: port control register 7 n = 7 to 0 figure c.7 port 7 block diagram
500 c.8 block diagrams of port 8 p8 n v cc pdr8 n internal data bus pcr8 n sby v ss pdr8: pcr8: n= 7 to 0 port data register 8 port control register 8 figure c-8 port 8 block diagram
501 c.9 block diagram of port 9 p9 n v cc pdr9 n pcr9 n sby figure c-9 port 9 block diagram
502 c.10 block diagram of port a pa n v cc pdra n internal data bus pcra n sby v ss pdra: port data register a pcra: port control register a n = 3 to 0 figure c.10 port a block diagram
503 c.11 block diagram of port b pb n internal data bus amr3 to amr0 a/d module v in n = 7 to 0 dec figure c-11 port b block diagram
504 appendix d port states in the different processing states table d-1 port states overview port reset sleep subsleep standby watch subactive active p1 7 to p1 0 high- impedance retained retained high- impedance * 1 retained functions functions p2 4 low retained retained retained retained functions functions p2 3 high p2 2 to p2 0 low p3 7 to p3 0 high- impedance * 2 retained retained high- impedance * 1 retained functions functions p4 3 high retained retained retained retained functions functions p4 2 to p4 0 high- impedance high- impedance p5 7 to p5 0 high- impedance retained retained high- impedance * 1 retained functions functions p6 7 to p6 0 high- impedance retained retained high- impedance retained functions functions p7 7 to p7 0 high- impedance retained retained high- impedance retained functions functions p8 7 to p8 0 high- impedance retained retained high- impedance retained functions functions p9 3 to p9 0 high- impedance retained retained high- impedance retained functions functions pa 3 to pa 0 high- impedance retained retained high- impedance retained functions functions pb 7 to pb 0 high- impedance high- impedance high- impedance high- impedance high- impedance high- impedance high- impedance notes: 1. high level output when mos pull-up is in on state. 2. reset output from p3 2 pin only.
505 appendix e list of product codes table e.1 product code lineup product type product code mark code package (hitachi package code) h8/3937 h8/3935 mask rom hd6433935x hd6433935( *** )x 100-pin tqfp (tfp-100b) series versions hd6433935w hd6433935( *** )w 100-pin tqfp (tfp-100g) h8/3936 mask rom hd6433936x hd6433936( *** )x 100-pin tqfp (tfp-100b) versions hd6433936w hd6433936( *** )w 100-pin tqfp (tfp-100g) h8/3937 mask rom hd6433937x hd6433937( *** )x 100-pin tqfp (tfp-100b) versions hd6433937w hd6433937( *** )w 100-pin tqfp (tfp-100g) ztat hd6473937x hd6473937x 100-pin tqfp (tfp-100b) versions hd6473937w hd6473937w 100-pin tqfp (tfp-100g) h8/3937r h8/3935r mask rom hd6433935rx hd6433935r( *** )x 100-pin tqfp (tfp-100b) series versions hd6433935rw hd6433935r( *** )w 100-pin tqfp (tfp-100g) h8/3936r mask rom hd6433936rx hd6433936r( *** )x 100-pin tqfp (tfp-100b) versions hd6433936rw hd6433936r( *** )w 100-pin tqfp (tfp-100g) h8/3937r mask rom hd6433937rx hd6433937r( *** )x 100-pin tqfp (tfp-100b) versions hd6433937rw hd6433937r( *** )w 100-pin tqfp (tfp-100g) ztat hd6473937rx hd6473937rx 100-pin tqfp (tfp-100b) versions hd6473937rw hd6473937rw 100-pin tqfp (tfp-100g) note: for mask rom versions, ( *** ) is the rom code.
506 appendix f package dimensions dimensional drawings of the h8/3937 series and h8/3937r series packages tfp-100b and tfp- 100g are shown in following figures f-1 and f-2, respectively. hitachi code jedec eiaj weight (reference value) tfp-100b conforms 0.5 g unit: mm *dimension including the plating thickness base material dimension 16.0 0.2 14 0.08 0.10 0.5 0.1 16.0 0.2 0.5 0.10 0.10 1.20 max *0.17 0.05 0 ?8 75 51 125 76 100 26 50 m *0.22 0.05 1.0 1.00 1.0 0.20 0.04 0.15 0.04 figure f-1 tfp-100b package dimensions
507 hitachi code jedec eiaj weight (reference value) tfp-100g conforms 0.4 g unit: mm *dimension including the plating thickness base material dimension 14.0 0.2 12 0.07 0.10 0.5 0.1 14.0 0.2 0.4 1.20 max *0.17 0.05 0 8 75 51 125 76 100 26 50 m *0.18 0.05 1.0 1.2 0.16 0.04 0.15 0.04 1.00 0.10 0.10 figure f-2 tfp-100g package dimensions
508
h8/3937 series, h8/3937r series hardware manual publication date: 1st edition, february 2001 published by: electronic devices sales & marketing group semiconductor & integrated circuits hitachi, ltd. edited by: technical documentation group hitachi kodaira semiconductor co., ltd. copyright ? hitachi, ltd., 2001. all rights reserved. printed in japan.


▲Up To Search▲   

 
Price & Availability of H83937R

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X